本篇文章主要給大家介紹百度地圖經(jīng)緯度轉(zhuǎn)換到騰訊地圖/Google 對應的經(jīng)緯度.需要的朋友可以參考下
實現(xiàn)目的:將百度地圖經(jīng)緯度 轉(zhuǎn)換到 騰訊地圖/Google 對應的經(jīng)緯度.
方法1:使用代碼進行轉(zhuǎn)換
存在的問題:轉(zhuǎn)換之后誤差大,基本不可用
- 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);
- }
方法2:
該網(wǎng)站提供轉(zhuǎn)換服務,坐標較為準確,可用,后臺調(diào)用沒有仔細研究
http://www.minigps.net/convert.html
方法3:
使用騰訊地圖,詳見1.html
騰訊地圖老版的地址:http://api.map.soso.com/doc_v2/example.html?sample-convertor-library#12map
最新的地址:http://lbs.qq.com/javascript_v2/doc/convertor.html
直接調(diào)用的地址<百度地圖轉(zhuǎn)為騰訊地圖>,points=經(jīng)緯度,傳入百度的即可:
http://apic.map.qq.com/translate/?type=3&points=114.041993,22.667204&output=jsonp&pf=jsapi&cb=qq.maps.__svcbi1x9al56.cbi1x9al9l0
坐標查詢地址:
http://api.map.baidu.com/lbsapi/getpoint/
http://lbs.qq.com/javascript_v2/case-run.html#sample-geocoding-reverse
總結:
由于騰訊的經(jīng)緯度和google經(jīng)緯度是同一個坐標系,百度經(jīng)緯度為自己的體系,目前網(wǎng)上搜索到的算法代碼,都不是十分精確,所以建議使用地圖開發(fā)方提供的Api進行轉(zhuǎn)換.
新聞熱點
疑難解答