Xaml 在Silverlight中将自定义图钉添加到Bing地图
我对Bing地图的概念非常陌生 要求:需要设计一个自定义图钉和Bing地图上的许多层Bing地图 完成的工作:创建了一个带有一个键和两个DLL的Bing地图,添加了多个图钉,使用MapPolygon在地图上添加了一个形状 问题:Xaml 在Silverlight中将自定义图钉添加到Bing地图,xaml,bing,silverlight-5.0,Xaml,Bing,Silverlight 5.0,我对Bing地图的概念非常陌生 要求:需要设计一个自定义图钉和Bing地图上的许多层Bing地图 完成的工作:创建了一个带有一个键和两个DLL的Bing地图,添加了多个图钉,使用MapPolygon在地图上添加了一个形状 问题: 我需要向Bing地图添加自定义图钉(我的项目文件夹中有一个图像,当指定位置时,我需要在Bing地图上显示该图像)。我已经通过了许多链接,没有一个对我有用。请告诉我在Bing地图上显示自定义图钉的方法 我需要在Bing地图上添加多个图层,但我对此知之甚少。因此,请引导我了
MapLayer
并在其中放置Pushpin
控件。您可以使用MapLayer.Position
attached属性将该地图层内的任何内容固定到地图上;这样,当用户移动地图时,它会显示该属性。该attached属性的类型为Location
,即at是Bing地图控件的专有属性,该控件包含经度(双精度)和纬度(双精度)值。如果需要绑定所述位置的集合,则可以在MapLayer
中使用MapItemsControl
将其ItemsSource
属性绑定到集合。您还可以创建数据模板;只需记住模板根目录必须使用MapLayer.Position
附加属性到规范通知其在地图上的位置。这可以绑定到任何位置
类型的值
<UserControl x:Class="MapControlInteractiveSdk.Tutorials.DataBinding.TutorialMapItemsControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:t="clr-namespace:MapControlInteractiveSdk.Tutorials.DataBinding"
xmlns:m="clr-namespace:Microsoft.Maps.MapControl;assembly=Microsoft.Maps.MapControl">
<UserControl.Resources>
<DataTemplate x:Key="LogoTemplate">
<!-- This doesn't have to be a pushpin control - it can be anything just apply
the "m:MapLayer.Position" property to whatever is the root of the
template.
-->
<m:Pushpin m:MapLayer.Position="{Binding Location}" />
</DataTemplate>
</UserControl.Resources>
<Grid x:Name="LayoutRoot" Background="White">
<m:Map CredentialsProvider="Your Key">
<m:MapLayer>
<m:MapItemsControl x:Name="ListOfItems"
ItemTemplate="{StaticResource LogoTemplate}"
ItemsSource="{Binding MyLocalizedEntities}">
</m:MapItemsControl>
</m:MapLayer>
<m:MapLayer>
<!-- You can have content in multiple layers: Latter layers are infront of former ones. -->
</m:MapLayer>
</m:Map>
</Grid>
</UserControl>