如何将图钉添加到Windows Phone 8.1地图控件?

问题描述:

我一直在寻找有关如何执行此任务的示例,但是我找不到一个清晰的示例.有人能指出我正确的方向吗?我迷路了...

I've been looking for examples on how to perform this task however i haven't been able to find a clear one. Can someone please point me in the right direction. I'm lost...

编辑/更新:

我已经按照以下示例添加了一些标记: http://www.microsoftvirtualacademy.com/Content /ViewContent.aspx?et=8698&m=8686&ct=29035

Ive manage to add some markers following the following example: http://www.microsoftvirtualacademy.com/Content/ViewContent.aspx?et=8698&m=8686&ct=29035

但是,如 MSDN文档所述所示,

不保证会显示MapIcon.当它隐藏时 遮盖了地图上的其他元素或标签.的可选标题 不保证会显示MapIcon.如果您没有看到文字, 通过增加 MapControl.

The MapIcon is not guaranteed to be shown. It may be hidden when it obscures other elements or labels on the map. The optional Title of the MapIcon is not guaranteed to be shown. If you don't see the text, zoom out by increasing the value of the ZoomLevel property of the MapControl.

无论如何,我都需要它可以显示的东西,几乎不可能找到有关如何执行此简单任务的简单示例! 我必须说我使用的是最新的Maps sdk,而不是以前的8.0.

I need something that its going to show no matter what, it has been almost impossible to find an simple example on how to perform this simple task! I must say im using the latest Maps sdk, not the previous 8.0.

我能够使用以下代码完成

I was able to do it using the following code

   public void AddPushpin(BasicGeoposition location, string text)
        {
            var pin = new Grid()
            {
                Width = 50,
                Height = 50,
                Margin = new Windows.UI.Xaml.Thickness(-12)
            };

            pin.Children.Add(new Ellipse()
            {
                Fill = new SolidColorBrush(Colors.DodgerBlue),
                Stroke = new SolidColorBrush(Colors.White),
                StrokeThickness = 3,
                Width = 50,
                Height = 50
            });

            pin.Children.Add(new TextBlock()
            {
                Text = text,
                FontSize = 12,
                Foreground = new SolidColorBrush(Colors.White),
                HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center,
                VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Center
            });

            MapControl.SetLocation(pin, new Geopoint(location));
            Map_MainMap.Children.Add(pin);
        }