在BingMap中如何添加任意思UI对像,与自定义Pusppin

You have 2 ways to go:

(1) Create any UIElement to pass into PushPinLayer.AddChild.  The AddChild method will accept and any UIElement, such as an image in this case:

MapLayer m_PushpinLayer =newMapLayer();Your_Map.Children.Add(m_PushpinLayer);Image image =newImage();
image.Source=ResourceFile.GetBitmap("Images/Me.png",From.This);
image.Width=40;
image.Height=40;
m_PushpinLayer.AddChild(image,newMicrosoft.Maps.MapControl.Location(42.658,-71.137),PositionOrigin.Center);

(2) Create a native PushPin objects to pass into PushpinLayer.AddChild, but first set it's Template property.  Note that PushPin's are ContentControls, and have a Template property that can be set from a Resource defined in XAML:

MapLayer m_PushpinLayer =newMapLayer();Your_Map.Children.Add(m_PushpinLayer);Pushpin pushpin =newPushpin();
pushpin.Template=Application.Current.Resources["PushPinTemplate"]as(ControlTemplate);
m_PushpinLayer.AddChild(pushpin,newMicrosoft.Maps.MapControl.Location(42.658,-71.137),PositionOrigin.Center);<ResourceDictionary
    xmlns="http://schemas.microsoft.com/client/2007"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"><ControlTemplate x:Key="PushPinTemplate"><Grid><EllipseFill="Green"Width="15"Height="15"/></Grid></ControlTemplate></ResourceDictionary>

 

<ControlTemplate x:Key="PushpinControlTemplate1" TargetType="Maps:Pushpin">            

<Grid >        

         <Image Source="/Images/chat.recording.png"   Height="20" Width="30"></Image>        

     </Grid>

        </ControlTemplate>

 

想要什么类型的 Pushpin,直接将ControlTemplate Grid放进什么东西去就可

转载于:https://www.cnblogs.com/ZL1911/p/3205133.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值