加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

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

发布时间:2020-12-14 02:08:04 所属栏目:Windows 来源:网络整理
导读:我一直在寻找有关如何执行此任务的示例,但我找不到明确的任务.有人可以指出我正确的方向.我迷路了… 编辑/更新: 我已设法按照以下示例添加一些标记: http://www.microsoftvirtualacademy.com/Content/ViewContent.aspx?et=8698m=8686ct=29035 但是,正如MSD
我一直在寻找有关如何执行此任务的示例,但我找不到明确的任务.有人可以指出我正确的方向.我迷路了…

编辑/更新:

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

但是,正如MSDN文档所述,

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.

解决方法

我能够使用以下代码完成它

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读