墨卡托与经纬度互转
export function mercatorTolonlat(xx, yy) {
let lonlat = {};
let x = (xx / 20037508.34) * 180;
let y = (yy / 20037508.34) * 180;
y =
(180 / Math.PI) *
(2 * Math.atan(Math.exp((y * Math.PI) / 180)) - Math.PI / 2);
lonlat.lon = x;
lonlat.lat = y;
return lonlat;
}
export function lonlatToMercator(lon, lat) {
var mercator = {};
let x = (lon * 20037508.34) / 180;
let y = Math.log(Math.tan(((90 + lat) * Math.PI) / 360)) / (Math.PI / 180);
y = (y * 20037508.34) / 180;
mercator.x = x;
mercator.y = y;
return mercator;
}
本文标题:墨卡托与经纬度互转
本文链接:https://www.haomeiwen.com/subject/pwtafjtx.html
网友评论