2015-11-07 28 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

将搜索相同。 –

相关问题