//经纬度转Web墨卡托dvec3 CMathEngine::lonLat2WebMercator(dvec3 lonLat){ dvec3 mercator; double x = lonLat.x *20037508.34/180; double y = log(tan((90+lonLat.y)*PI/360))/(PI/180); y = y *20037508.34/180; mercator.x = x; mercator.y = y; return mercator;}//Web墨卡托转经纬度dvec3 CMathEngine::WebMercator2lonLat( dvec3 mercator ){ dvec3 lonLat; double x = mercator.x/20037508.34*180; double y = mercator.y/20037508.34*180; y= 180/PI*(2*atan(exp(y*PI/180))-PI/2); lonLat.x = x; lonLat.y = y; return lonLat;}第二种方法://经度转墨卡托function handle_x(x) { return (x / 180.0) * 20037508.34;}//纬度转墨卡托function handle_y(y) { if (y > 85.05112) { y = 85.05112; } if (y < -85.05112) { y = -85.05112; } y = (Math.PI / 180.0) * y; var tmp = Math.PI / 4.0 + y / 2.0; return 20037508.34 * Math.log(Math.tan(tmp)) / Math.PI;}//墨卡托转经度function handle_me_x(x){ return x/20037508.34*180;}//墨卡托转纬度function handle_me_y(my){ var mmy = my/20037508.34*180; y= 180/Math.PI*(2*Math.atan(Math.exp(mmy*Math.PI/180))-Math.PI/2); return y;}