In the Baidu map development process, it is possible to encounter some questions about coordinate conversion, the following on the project in the process of some of the conversion methods and some of the methods collected online to write down, in case of a rainy future
1. National Survey Bureau coordinates to Baidu coordinates
/*** National Survey Bureau to convert Baidu latitude and longitude *@paramPoint *@return */ Public Staticlatlng Gcjtobaidu (latlng point) {//Double x = gg_lon, y = Gg_lat; Doublex = point.longitude, y =Point.latitude; Doublez = MATH.SQRT (x * x + y * y) + 0.00002 * Math.sin (Y *x_pi); Doubletheta = math.atan2 (y, x) + 0.000003 * MATH.COS (x *x_pi); DoubleBd_lon = Z * Math.Cos (theta) + 0.0065; DoubleBd_lat = Z * Math.sin (theta) + 0.006; LATLNG Point1=Newlatlng (Bd_lat,bd_lon); returnpoint1; }
2. Next is the Baidu Map development document above the coordinate conversion method
Here to use the Com.baidu.mapapi.map package below the projection class, we want to achieve coordinate conversion first to get to the Baidu map projection
Method:
Projection Mprojection=mapview.getmap (). getprojection ()
Then use Mprojection to call the Baidu API has been packaged in the coordinate conversion method
- Screen coordinates go to screen coordinates
Return value method
LATLNG fromscreenlocation (Point point)
2. Screen coordinates go to geographical coordinates
This method converts the distance in meters (along the equator) at the current zoom level to a distance in pixels (horizontal) as the unit of measure.
Return value method
float Meterstoequatorpixels (float meters)
3. Geo-coordinates to OpenGL coordinates
Used in the Onmapdrawframe function of Onmapdrawframecallback.
Return value method
PointF toopengllocation (latlng location, Mapstatus mapstatus)
4. Geographical coordinates to screen coordinates
Return value method
Point Toscreenlocation (latlng location)
Baidu Map Coordinate conversion