Ben*_*Ben 4 c# xaml windows-runtime winrt-xaml uwp
我想在Windows 10应用程序中向MapControl添加一个Pushpin,但似乎自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);
Run Code Online (Sandbox Code Playgroud)
但是不再识别图钉类型......
UWP中的地图控件几乎没有变化 - 请查看Windows.UI.Xaml.Controls.Maps命名空间.
至于添加Pushpins(POI),你可以通过几种方式完成.例如:
// 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;
Run Code Online (Sandbox Code Playgroud)
有关更多指南,请访问MSDN.
| 归档时间: |
|
| 查看次数: |
4955 次 |
| 最近记录: |