2015-10-24 1 views
0

В Интернете много уроков, рассказывающих о бинговых картах WinRT для Store Apps. Это то, что я хочу сделать с WPF:WPF Bing Maps С REST: Невозможно выяснить, как добавить маршруты

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

я переводил этот учебник для WPF. Однако на картах WPF bing нет, например, MapShapeLayer, что делает невозможным следовать.

Как реализовать это с помощью элементов управления WPF Bing?

ответ

0

Ну, я никогда не добавлял элементы на карту программно, но я считаю, что вы просто добавляете их на карты 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> 
Смежные вопросы