经纬度和墨卡托坐标相互转换

//经纬度转墨卡托
public void loc_to_mercator(double lon, double lat,ref double miX,ref double minY)
        {
            double x = lon;
            double y = Math.Log(Math.Tan((lat / 180 * Math.PI + Math.PI / 2) / 2)) * 180 / Math.PI;
            miX = x * 20037508.3427892 / 180;
            minY = y * 20037508.3427892 / 180;
        }

//摩卡脱转经纬度
public void mercator_to_loc(double mercator_x, double mercator_y, ref double lon, ref double lat)
        {
            double x = mercator_x / 20037508.3427892 * 180;
            double y = mercator_y / 20037508.3427892 * 180;
            lon = x;
            lat = 180 / Math.PI * (2 * Math.Atan(Math.Exp(y * Math.PI / 180)) - Math.PI / 2);
        }

  

原文地址:https://www.cnblogs.com/dushaojun/p/8419389.html