Back to Devexpress

AzureRouteIsochroneDataProvider Class

wpf-devexpress-dot-xpf-dot-map-ec014f15.md

latest6.5 KB
Original Source

AzureRouteIsochroneDataProvider Class

Allows you to use the Azure Maps service to calculate an isochrone and display it on the map.

Namespace : DevExpress.Xpf.Map

Assembly : DevExpress.Xpf.Map.v25.2.dll

NuGet Package : DevExpress.Wpf.Map

Declaration

csharp
public class AzureRouteIsochroneDataProvider :
    AzureMapDataProviderBase
vb
Public Class AzureRouteIsochroneDataProvider
    Inherits AzureMapDataProviderBase

Remarks

The AzureRouteIsochroneDataProvider implements the Azure Maps service. Assign such an object to the InformationLayer.DataProvider property to enable the service and display an isochrone (an area around an origin point). You can calculate the area based on travel time or distance.

Azure Maps services support JSON response formats. Install the System.Text.Json package in projects that target .NET Framework to parse the Azure server response and display information on a DevExpress Map control.

Call one of the CalculateIsochroneByDistance method overloads to calculate an isochrone based on travel distance.

Call one of the CalculateIsochroneByTime method overloads to calculate an isochrone based on travel time.

When you call CalculateIsochroneByTime or CalculateIsochroneByDistance methods, use the options (AzureRouteIsochroneOptions) parameter to specify route options.

The following settings are available:

AzureRouteIsochroneOptions.AvoidTypesExcludes specified road or transportation types from the route.AzureRouteIsochroneOptions.ExtendedRouteDefinitionsSpecifies additional route calculation parameters (definitions).AzureRouteIsochroneOptions.TravelModeSpecifies the transportation / commute mode.

The following example calculates and plots an isochrone. The code sets the origin point and travel distance limit (10 km).

xaml
<Window xmlns:dxm="http://schemas.devexpress.com/winfx/2008/xaml/map"...>
    <Window.Resources>
        <sys:String x:Key="azureKey">Your AzureMaps key here.</sys:String>
    </Window.Resources>
    <Grid>
        <dxm:MapControl Loaded="MapControl_Loaded" Grid.Column="0"
                        x:Name="mapControl" ToolTipEnabled="True" 
                        ShowSearchPanel="False" ZoomLevel="3">
            <dxm:MapControl.ZoomTrackbarOptions>
                <dxm:ZoomTrackbarOptions Visible="False" />
            </dxm:MapControl.ZoomTrackbarOptions>
            <dxm:ImageLayer>
                <dxm:AzureMapDataProvider AzureKey="{StaticResource azureKey}" Tileset="BaseRoad"/>
            </dxm:ImageLayer>
            <dxm:InformationLayer x:Name="infoLayer">
                <dxm:AzureRouteIsochroneDataProvider AzureKey="{StaticResource azureKey}" 
                                                     x:Name="isochroneProvider" 
                                                     LayerItemsGenerating="OnLayerItemsGenerating" />
            </dxm:InformationLayer>
        </dxm:MapControl>
    </Grid>
</Window>
csharp
using DevExpress.Xpf.Map;
using System.Windows;

namespace WpfMapExample {
    public partial class MainWindow : Window {
        public MainWindow() {
            InitializeComponent();
        }
        private void MapControl_Loaded(object sender, RoutedEventArgs e) {
            isochroneProvider.CalculateIsochroneByDistance(
                new RouteWaypoint("", new GeoPoint(36.1532403246368, -86.7701703811725)), 
                maxDistanceMeters: 10000,
                new AzureRouteIsochroneOptions { AvoidTypes = AzureRouteAvoidType.Motorways });
        }
        private void OnLayerItemsGenerating(object sender, LayerItemsGeneratingEventArgs args) {
            mapControl.ZoomToFit(args.Items);
        }
    }
}
vb
Imports DevExpress.Xpf.Map
Imports System.Windows

Namespace WpfMapExample
    Public Partial Class MainWindow
        Inherits Window

        Public Sub New()
            InitializeComponent()
        End Sub

        Private Sub MapControl_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
            isochroneProvider.CalculateIsochroneByDistance(New RouteWaypoint("", New GeoPoint(36.1532403246368, -86.7701703811725)), maxDistanceMeters:=10000, New AzureRouteIsochroneOptions With {
                .AvoidTypes = AzureRouteAvoidType.Motorways
            })
        End Sub

        Private Sub OnLayerItemsGenerating(ByVal sender As Object, ByVal args As LayerItemsGeneratingEventArgs)
            mapControl.ZoomToFit(args.Items)
        End Sub
    End Class
End Namespace

Implements

ISupportWebRequest

Inheritance

Object DispatcherObject DependencyObject Freezable MapDependencyObject InformationDataProviderBase WebInformationDataProvider<DevExpress.Map.Native.JsonProvidedEventArgs> AzureMapDataProviderBase AzureRouteIsochroneDataProvider

See Also

AzureRouteIsochroneDataProvider Members

DevExpress.Xpf.Map Namespace