//bd09转Gcj02坐标系(百度坐标系转火星坐标系,纬度,经度)
Gpsbd09_To_Gcj02: function (bd_lat, bd_lon) {
var x = bd_lon - 0.0065, y = bd_lat - 0.006;
var z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * Math.PI);
var theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * Math.PI);
var gg_lon = z * Math.cos(theta);
var gg_lat = z * Math.sin(theta);
return { gg_lat, gg_lon };
},
//Gcj02转bd09坐标系(火星坐标系转百度坐标系,经度,纬度)
gcj02tobd09: function (lng, lat) {
var x_PI = 3.14159265358979324 * 3000.0 / 180.0;
var PI = 3.1415926535897932384626;
var a = 6378245.0;
var ee = 0.00669342162296594323;
var z = Math.sqrt(lng * lng + lat * lat) + 0.00002 * Math.sin(lat * x_PI);
var theta = Math.atan2(lat, lng) + 0.000003 * Math.cos(lng * x_PI);
var bd_lng = z * Math.cos(theta) + 0.0065;
var bd_lat = z * Math.sin(theta) + 0.006;
return [bd_lng, bd_lat]
},
你试试