本文主要是介绍高德与百度经纬度坐标相互转换,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
//百度坐标转换为高德坐标
function bd_convent_gd(points) {var arr = points.split(" ");var bd_lng = arr[0];var bd_lat = arr[1];var pi = 3.14159265358979324 * 3000.0 / 180.0;var x = bd_lng - 0.0065;var y = bd_lat - 0.006;var z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * pi);var theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * pi);var gd_lng = z * Math.cos(theta);var gd_lat = z * Math.sin(theta);var data = gd_lng + " " + gd_lat;return data;
}//高德坐标转换为百度坐标
function gd_convent_bd(gd_lng, gd_lat){var pi = 3.14159265358979324 * 3000.0 / 180.0;var x = gd_lng;var y = gd_lat;var z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * pi);var theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * pi);var bd_lng = z * Math.cos(theta) + 0.0065;var bd_lat = z * Math.sin(theta) + 0.006;var data = bd_lng.toFixed(6) + " " + bd_lat.toFixed(6);return data;
}
这篇关于高德与百度经纬度坐标相互转换的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!