【问题标题】:Add Pushpin to MapControl in UWP在 UWP 中将图钉添加到 MapControl
【发布时间】:2016-02-08 10:31:12
【问题描述】:

我想将 Pushpin 添加到 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);

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

【问题讨论】:

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


    【解决方案1】:

    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

    【讨论】:

    • 当用户将MapIcon放到某个经纬度时,是否可以拖动这个MapIcon并获取位置?
    • @KinjanBhavsar 我还没玩过那么多,但我会在 MapControl 类及其事件中进行搜索。
    • 将搜索相同的内容。
    • 检查了 MapControl 的事件得到了一个 CenterChanged - Occurs when the value of the Center property of the MapControl changes. 会有帮助吗?
    • @KinjanBhavsar 我想它可能是 - 试一试。
    猜你喜欢
    • 1970-01-01
    • 2018-12-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-07
    相关资源
    最近更新 更多