3

我正在开发Windows Phone 8.1应用程序,我想显示Yandex Maps而不是Bing Maps在 MapControl 中显示。我已经使用 yandex url 设置了一个新的 tile 数据源。它可以工作,但瓷砖显示的垂直偏移量很小。

仅偏移不是问题,但它会影响地标 - 它们在 yandex 瓷砖上显示在错误的位置,但在 bing 瓷砖上是正确的。

问题不在于坐标,因为我从浏览器中的原始 yandex 地图中选择它们。

在下面的示例中,彩色图块由 yandex 提供,灰色形状来自 bing 地图。

平铺偏移示例

在 MapControl 中设置 yandex 瓦片:

HttpMapTileDataSource dataSource = new HttpMapTileDataSource("http://vec02.maps.yandex.net/tiles?l=map&x={x}&y={y}&z={zoomlevel}");
MapTileSource tileSource = new MapTileSource(dataSource);
MyMapControl.TileSources.Add(tileSource);

我试图拦截 MapControl 的平铺请求并减少y坐标的值,但结果完全错误。

拦截请求和修改值的结果y

在此处输入图像描述

MSDN:MapControl 平铺覆盖

4

2 回答 2

2
    public static Point WGS84ToBing(Point coordinate)
    {
        double d = coordinate.X * Math.PI / 180, m = coordinate.Y * Math.PI / 180, l = 6378137, k = 0.0818191908426, f = k * Math.Sin(m);
        double h = Math.Tan(Math.PI / 4 + m / 2), j = Math.Pow(Math.Tan(Math.PI / 4 + Math.Asin(f) / 2), k), i = h / j;

        return new Point(l * d, l * Math.Log(i));
    }

    public static Point BingtoWGS84Mercator(Point point)
    {
        double lon = (point.X / 20037508.34) * 180;
        double lat = (point.Y / 20037508.34) * 180;

        lat = 180 / Math.PI * (2 * Math.Atan(Math.Exp(lat * Math.PI / 180)) - Math.PI / 2);

        return new Point(lon, lat);
    }

使用示例:

    HttpMapTileDataSource dataSource = new HttpMapTileDataSource("http://vec02.maps.yandex.net/tiles?l=map&v=2.2.3&x={x}&y={y}&z={zoomlevel}");

    MapTileSource tileSource = new MapTileSource(dataSource)
    {
        Layer = MapTileLayer.BackgroundReplacement
    };

    map.Style = MapStyle.None;
    map.TileSources.Add(tileSource);

    Point bingPoint = WGS84ToBing(new Point(47.245252, 56.139498));
    Point yandexCoordinates = BingtoWGS84Mercator(new Point(bingPoint.X, bingPoint.Y));

    map.Center = new Geopoint(new BasicGeoposition() { Longitude = yandexCoordinates.X, Latitude = yandexCoordinates.Y });
于 2016-02-03T22:25:58.823 回答
1

这是因为 Yandex Maps 和 Bing Maps 的地图投影略有不同。我不是投影专家,但是,您可以看到MercatorProjection(为 Bing 地图实现)和MercatorProjectionYandex(为 Yandex 地图实现)类的区别,这些类是为 Windows Forms & Presentation 的 Great Maps实现的。

于 2015-01-04T10:27:56.170 回答