Windows 10 Creators升级(内部版本15063)后,移动或缩放地图本身时,我的UWP应用中的MapControl子级不再固定在地图上。
从特定的缩放级别,我注意到在缩放地图时行为上的差异。从这一点来看,存在明显的视觉“球”效果。难以描述,但我认为地图并非纯平(2D)。

在此处查看内部版本14393的所需输出,因为您可以看到在移动或缩放地图时雷达覆盖图保持在相同位置:
图片:https://www.regenthetin.nl/files/desired_behaviour_v14393.gif

在版本15063上不希望的输出,叠加层随地图缓慢移动:
图片:https://www.regenthetin.nl/files/undesired_behaviour_v15063.gif

负责的代码块:

片段1

// Add children to MapControl at specified location
var radarImgPosition = new Geopoint(new BasicGeoposition()
{
    Latitude = 59.60,
    Longitude = -12.00
});

RadarMap.Children.Clear();
if (RadarMap.Children.Count == 0)
{
    RadarMap.Children.Add(radarImg);
    MapControl.SetLocation(radarImg, radarImgPosition);
}


片段2

private void RadarMap_ZoomLevelChanged(MapControl sender, object args)
{
    Windows.Foundation.Point southWestPoint;
    RadarMap.GetOffsetFromLocation(new Geopoint(new BasicGeoposition()
    {
        Longitude = -11.9687,
        Latitude = 46.9106
    }), out southWestPoint);

    Windows.Foundation.Point northEastPoint;
    RadarMap.GetOffsetFromLocation(new Geopoint(new BasicGeoposition()
    {
        Longitude = 15.5080,
        Latitude = 60.0247
    }), out northEastPoint);

    double radarImgWidth = northEastPoint.X - southWestPoint.X;
    double radarImgHeight = Math.Abs(northEastPoint.Y - southWestPoint.Y);

    DisplayInformation displayInformation = DisplayInformation.GetForCurrentView();
    double scaleValue = (displayInformation.RawPixelsPerViewPixel * 100.0);

    radarImg.Height = (radarImgHeight) / (scaleValue / 100);
    radarImg.Width = (radarImgWidth) / (scaleValue / 100);
}


我已经研究了几个小时,但是到目前为止我还没有找到解决方案。我希望有一个人可以帮助我!

开发配置:Visual Studio 2017 i.c.m. Windows 10创建者更新了SDK。

最佳答案

我找到了解决问题的方法,并且感觉到您的亲戚。背景:我的MapControl有一个XAML元素作为子元素,当该元素可见时,我设置并更改了位置。这个孩子表现出与线程打开器已经描述的相同的效果。

事实证明,新的MapControl(创建者的更新)在放置孩子时也考虑了海拔高度。换句话说,现在XAML子项位于空间中而不是在襟翼图上。我的猜测是这是MapControl的新伪3D效果产生的结果。

解决方案是通过指定地形参考系统并将海拔高度设置为0,将儿童放置在地面上:

        var location = new Geopoint(new BasicGeoposition
             {
               Latitude = currentLatitude,
               Longitude = currentLongitude,
               Altitude = 0
             },
             AltitudeReferenceSystem.Terrain);
        MapControl.SetLocation(myChild, location);

08-15 17:37