你试过微软提供的交互式 SDK吗?它帮助了我。
似乎您只需要在其中放置一个MapLayer
并放置Pushpin
控件。您可以使用MapLayer.Position
附加属性将该地图图层中的任何内容固定到地图上;这样当用户移动地图时它会说。此附加属性属于Location
Bing 地图控件专有的类型,该控件包含经度(双精度)和纬度(双精度)值。如果您需要绑定所述位置的集合,则可以使用将其属性绑定到集合的MapItemsControl
内部。您还可以创建数据模板;请记住,您的模板根必须使用附加属性来指定其在地图上的位置。这可以绑定到任何类型的值。MapLayer
ItemsSource
MapLayer.Position
Location
<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>