Baidu Map Coordinate conversion

Source: Internet
Author: User
Tags cos sin

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
  

    1. 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.