如何将图钉添加到Windows Phone 8.1地图控件? [英] How do i add a pushpin to a Windows Phone 8.1 Map Control?

查看:103
本文介绍了如何将图钉添加到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);
        }

这篇关于如何将图钉添加到Windows Phone 8.1地图控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆