Skip to main content
All docs
V26.1
  • AzureRouteDataProvider.CalculateRoute(List<RouteWaypoint>, AzureRouteOptions) Method

    Calculates a route based on origin, destination, waypoints, and calculation options.

    Namespace: DevExpress.XtraMap

    Assembly: DevExpress.XtraMap.v26.1.dll

    NuGet Package: DevExpress.Win.Map

    Declaration

    public void CalculateRoute(
        List<RouteWaypoint> waypoints,
        AzureRouteOptions options
    )

    Parameters

    Name Type Description
    waypoints List<RouteWaypoint>

    A list of RouteWaypoint objects.

    options AzureRouteOptions

    An AzureRouteOptions object that defines route calculation options passed to the Azure Maps Route service.

    Remarks

    Call one of the AzureRouteDataProvider.CalculateRoute method overloads to calculate a route between the origin and destination, passing through the specified waypoints.

    The following example calculates a car-optimized route through the specified waypoints:

    using DevExpress.XtraMap;
    // ...
    const string key = "your key";
    // ...
    private void Form1_Load(object sender, EventArgs e) {
        MapControl map = new MapControl();
        // Specify the map position on the form.           
        map.Dock = DockStyle.Fill;
        // Create a layer.
        ImageLayer image = new ImageLayer();
        image.DataProvider = new AzureMapDataProvider(){
            AzureKey = key,
        };
        AzureRouteDataProvider routeProvider = new AzureRouteDataProvider();
        routeProvider.AzureKey = key;
        // Create three waypoints and add them to the route waypoints list.
        List<RouteWaypoint> waypoints = new List<RouteWaypoint>();
        waypoints.Add(new RouteWaypoint("NY", new GeoPoint(41.145556, -73.995)));
        waypoints.Add(new RouteWaypoint("Oklahoma", new GeoPoint(36.131389, -95.937222)));
        waypoints.Add(new RouteWaypoint("Las Vegas", new GeoPoint(36.175, -115.136389)));
        // Call the AzureRouteDataProvider.CalculateRoute method.
        azureRoute.CalculateRoute(waypoints, new AzureRouteOptions() {
            TravelMode = AzureTravelMode.Car,
            AvoidTypes = AzureRouteAvoidType.AlreadyUsedRoads
        });
        InformationLayer route = new InformationLayer();
        route.DataProvider = routeProvider;
        map.Layers.AddRange(new LayerBase[] { image, route});
        this.Controls.Add(map);
    }
    
    See Also