在 UWP 中将图钉添加到 MapControl

Add Pushpin to MapControl in UWP

我想在 Windows 10 应用程序中将图钉添加到 MapControl,但似乎自 Windows 8.1 以来该控件已消失。

就这么简单:

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);

但是图钉类型不再被识别...

地图控件在 UWP 中变化不大 - 请查看 Windows.UI.Xaml.Controls.Maps namespace

至于添加图钉 (POI),您可以 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