将屏幕点转换为 SP 4326

Convert Screen Point to SP 4326

我正在使用 Esri for .NET。我使用 ScreenToLocation 函数通过鼠标单击来捕获屏幕坐标。如何将此地图点转换为 4326 的 SP?

MapPoint mapPoint = Mapview.ScreenToLocation(screenPoint);

我的地图点不在我在地图上单击的位置。我得到的坐标为 5423799.44921864,-267641.097678069

您使用的是 windows 商店的 ArcGIS 运行时还是 wpf 的运行时?

无论如何,您将获得 WebMercator 积分。为了在空间参考之间进行转换,您需要在 wpf or the GeometryEngine on the winstore

上使用 GeometryService 的项目方法

或者,如果您更喜欢通过代码将 WebMercator (102100/3857) 同步转换为 WGS84 (4326),您可以使用:

private const double R_MAJOR = 6378137.0;
private const double R_MINOR = 6356752.3142;

public MapPoint PointToWGS84(double x, double y)
{        
    double originShift = 2 * Math.PI * R_MAJOR / 2.0;
    double mx = (x / originShift) * 180.0;
    double my = (y / originShift) * 180.0;
    my = (180 / Math.PI) * (2 * Math.Atan(Math.Exp(my * Math.PI / 180.0)) - Math.PI / 2.0);
    return new MapPoint(mx, my, new SpatialReference(WGS84));
}

从 WGS84 到 WM

public MapPoint PointToWM(double x, double y)
{
    double originShift = 2 * Math.PI * R_MAJOR / 2.0;
    double mx = x * originShift / 180.0;
    double my = Math.Log(Math.Tan((90.0 + y) * Math.PI / 360.0)) / (Math.PI / 180.0);
    my = my * originShift / 180.0;
    return new MapPoint(mx, my, new SpatialReference(102100));
}

请注意此代码仅适用于 WM to/from WGS。对于其他转换,您必须始终使用 GeometryService