Baidu map latitude and longitude conversion to Tencent map/google corresponding latitude and longitude _php example

Source: Internet
Author: User
Tags cos sin

To achieve the goal: the Baidu map latitude and longitude conversion to the Tencent map/google corresponding latitude and longitude degree.

Method 1: Use code to convert

The problem: After the conversion, the error is large, basically not available

public static void convert_bd09_to_gcj02 (double lat, double LNG) {
      double x_pi = Math. PI * 3000.0/180.0;
      Double x = lng-0.0065, y = lat-0.006;
      Double z = Math. SQRT (x * x + y * y)-0.00002 * Math.sin (y * x_pi);
      Double theta = math.atan2 (y, x)-0.000003 * MATH.COS (x * x_pi);
      LNG = Z * Math. cos (theta);
      Lat = z * Math. Sin (theta);
      
      System. Out.println (LNG);
      System. OUT.PRINTLN (LAT);
}

Method 2:

The site provides conversion services, the coordinates are more accurate, available, background calls are not carefully studied

Http://www.minigps.net/convert.html

Method 3:

Use the Tencent map for details, see 1.html

Tencent map old version of the address: http://api.map.soso.com/doc_v2/example.html?sample-convertor-library

Latest Address: http://lbs.qq.com/javascript_v2/doc/convertor.html

Direct call to the address < Baidu map into Tencent map >,points= latitude and longitude, the incoming Baidu can:

http://apic.map.qq.com/translate/?type=3&points=114.041993,22.667204&output=jsonp&pf=jsapi&cb= Qq.maps.__svcbi1x9al56.cbi1x9al9l0

Coordinate query Address:

http://api.map.baidu.com/lbsapi/getpoint/
Http://lbs.qq.com/javascript_v2/case-run.html#sample-geocoding-reverse

Summarize:

Because of Tencent's latitude and longitude and Google latitude and longitude is the same coordinate system, Baidu latitude and longitude for their own system, the current online search algorithm code, are not very accurate, so we recommend the use of Map developers to provide the API conversion.

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.