2017-04-06 88 views
1

在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。

+0

什麼是你的項目目標SDK? –

+0

嗨Stefano,我將目標更改爲最新版本(15063)。但是,定位較低版本時MapControl的行爲是相同的。這非常煩人,如果沒有解決方案可用,我將切換到Google地圖並將其嵌入到瀏覽器元素中。令人失望,但保證相同用戶體驗的唯一途徑。你有其他建議嗎? –

+0

這是一個錯誤,因爲如果你定位舊的SDK,行爲不應該改變。 您應該向Microsoft報告此錯誤。 –

回答

1

我發現了我的問題的解決方案,我感覺你的是相關的。背景:我的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);