WPF Bing Maps With REST:不知道如何添加路由

本文关键字:何添加 添加 路由 不知道 Maps Bing With REST WPF | 更新日期: 2023-09-27 18:19:02

网上有很多关于WinRT bing地图的教程。这就是我想对WPF做的:

https://rbrundritt.wordpress.com/2012/12/12/geocoding-and-routing-in-bing-maps-windows-store-apps-native/

我正在把这个教程翻译成WPF。然而,在WPF bing地图中,没有MapShapeLayer,例如,使这无法遵循。

如何使用WPF Bing控件实现这一点?

WPF Bing Maps With REST:不知道如何添加路由

我从未以编程方式向地图添加项目,但我相信您只需将它们添加到地图的Children属性中。我尝试坚持使用MVVM模式,因此我依赖绑定和底层视图模型来相应地更新映射。下面是我的一个项目中的XAML示例,我认为它将引导您朝着正确的方向前进:

  <bingControl:Map x:Name="DirectionsMap"
                   HorizontalAlignment="Stretch"
                   VerticalAlignment="Stretch"
                   AnimationLevel="Full"
                   Background="{StaticResource MapBackgroundBrush}"
                   CredentialsProvider="<YourCredentialsHere>"
                   ScaleVisibility="Collapsed"
                   ZoomLevel="5">
     <bingControl:Pushpin x:Name="StartPushin"
                          Width="Auto"
                          Height="Auto"
                          Panel.ZIndex="50"
                          Content="{Binding StartAddress.Name}"
                          Location="{Binding StartAddress.Location}"
                          Style="{StaticResource DirectionsEndpointPushpinStyle}" />
     <bingControl:Pushpin x:Name="DestinationPushpin"
                          Width="Auto"
                          Height="Auto"
                          Panel.ZIndex="50"
                          Content="{Binding DestinationAddress.Name}"
                          Location="{Binding DestinationAddress.Location}"
                          Style="{StaticResource DirectionsEndpointPushpinStyle}" />
     <bingControl:MapItemsControl x:Name="DirectionsEdges"
                                  Panel.ZIndex="10"
                                  ItemsSource="{Binding DirectionsResult.RoutePath}">
        <bingControl:MapItemsControl.ItemTemplate>
           <DataTemplate>
              <bingControl:MapPolyline Panel.ZIndex="20"
                                       Locations="{Binding ''}"
                                       Stroke="#5968F7"
                                       StrokeThickness="4" />
           </DataTemplate>
        </bingControl:MapItemsControl.ItemTemplate>
     </bingControl:MapItemsControl>
  </bingControl:Map>