c# - 在 UWP 中将图钉添加到 MapControl

标签 c# xaml windows-runtime winrt-xaml uwp

我想在 Windows 10 应用程序中将图钉添加到 MapControl,但该控件似乎从 Windows 8.1 开始就消失了。

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

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

最佳答案

map 控件在 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 .

关于c# - 在 UWP 中将图钉添加到 MapControl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33580993/

相关文章:

xaml - 3 Pane 循环滚动面板 - 建议

c# - 使用 Rx 同步异步事件

c# - 在创建 silverlight 页面期间触发的最后一个事件是什么

c# - 如何上线店铺审核?

c# - 在 XAML 中过滤空值

c# - 在 silverlight 应用程序中显示 HTML

c# - 从 Windows Phone 8.1 运行时组件访问 CoreWindow

c# - 根据 AD 组检查用户登录

c# - 使用所有备份集通过 SMO 恢复数据库

c# - 选择 datagridview 单元格时显示工具提示