2015-11-07 63 views
4

我想在Windows 10應用程序的MapControl中添加圖釘,但似乎自Windows 8.1以後控件就消失了。將圖釘添加到UWP中的MapControl中

Pushpin

它是如此簡單:

Pushpin locationPushpin = new Pushpin();      
locationPushpin.Background = new SolidColorBrush(Colors.Purple); 
locationPushpin.Content = "You are here"; 
locationPushpin.Tag = "locationPushpin"; 
locationPushpin.Location = watcher.Position.Location; 
this.map.Children.Add(locationPushpin); 
this.map.SetView(watcher.Position.Location, 18.0); 

但圖釘型不再被認可......

回答

5

地圖控制在UWP幾乎沒有變化 - 看看Windows.UI.Xaml.Controls.Maps namespace

至於添加圖釘(POIs),你可以do it in couple of ways。例如:

// get position 
Geopoint myPoint = new Geopoint(new BasicGeoposition() { Latitude = 51, Longitude = 0 }); 
//create POI 
MapIcon myPOI = new MapIcon { Location = myPoint, NormalizedAnchorPoint = new Point(0.5, 1.0), Title = "My position", ZIndex = 0 }; 
// add to map and center it 
myMap.MapElements.Add(myPOI); 
myMap.Center = myPoint; 
myMap.ZoomLevel = 10; 

有關更多指南visit MSDN

+0

當用戶在某些經度和緯度上放置MapIcon時,是否可以拖動此MapIcon並獲取位置? –

+0

@KinjanBhavsar我還沒有玩過那麼多,但我會在* MapControl *類和它的事件中搜索。 – Romasz

+0

將搜索相同。 –

相關問題