在W10创作者更新后,UWP MapControl儿童不再定位
问题描述:
在Windows 10 Creators升级(构建15063)后,我的UWP应用程序中的MapControl儿童在移动或缩放地图时不再固定在地图上。 从特定的缩放级别,我注意到放大地图时行为的差异。从这一点来看,视觉效果显着。很难描述,但我认为地图不是纯粹的平面(2D)。在W10创作者更新后,UWP MapControl儿童不再定位
这里查看构建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);
}
我在它调查了几个小时,但我没有找到一个解决方案为止。我希望有一个人可以帮助我!
Dev config:Visual Studio 2017 i.c.m. Windows 10 Creator更新SDK。
答
我发现了我的问题的解决方案,我感觉你的是相关的。背景:我的MapControl有一个XAML元素作为子元素,并且在元素可见时设置和更改位置。这个孩子表现出与开线人员已经描述的相同的效果。
事实证明,新的MapControl(创作者更新)在定位孩子时也考虑了高度。换句话说,现在XAML的孩子被定位在空间中,而不是在皮瓣地图上。我的猜测是关于MapControl的新伪3D效果的结果。
的解决方案是通过specifing地形参考系统,并设置高度为0位置的子到表面:
var location = new Geopoint(new BasicGeoposition
{
Latitude = currentLatitude,
Longitude = currentLongitude,
Altitude = 0
},
AltitudeReferenceSystem.Terrain);
MapControl.SetLocation(myChild, location);
什么是你的项目目标SDK? –
嗨Stefano,我将目标更改为最新版本(15063)。但是,定位较低版本时MapControl的行为是相同的。这非常烦人,如果没有解决方案可用,我将切换到Google地图并将其嵌入到浏览器元素中。令人失望,但保证相同用户体验的唯一途径。你有其他建议吗? –
这是一个错误,因为如果你定位旧的SDK,行为不应该改变。 您应该向Microsoft报告此错误。 –