Skip to main content
All docs
V23.2

BingRouteResult.WaypointsOrder Property

Returns an array of waypoint indexes.

Namespace: DevExpress.Xpf.Map

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

NuGet Package: DevExpress.Wpf.Map

Declaration

public int[] WaypointsOrder { get; }

Property Value

Type Description
Int32[]

An array of indexes.

Remarks

If the BingRouteOptions.OptimizeWaypoints property is set to true, the WaypointsOrder property returns waypoint indexes in sorted order. Note that the first and last waypoint positions are not changed when waypoints are optimized.

The following example shows how to obtain a list of optimized waypoint indexes:

<dx:ThemedWindow
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
    xmlns:dxm="http://schemas.devexpress.com/winfx/2008/xaml/map" 
    x:Class="WaypointOptimization.MainWindow"
    Title="MainWindow" Height="800" Width="1000" Loaded="ThemedWindow_Loaded">
    <Grid>
        <dxm:MapControl x:Name="mapControl">
            <dxm:ImageLayer>
                <dxm:BingMapDataProvider BingKey="Your Bing key here." 
                                         Kind="RoadLight" />
            </dxm:ImageLayer>
            <dxm:InformationLayer x:Name="infoLayer" DataRequestCompleted="OnDataRequestCompleted">
                <dxm:BingRouteDataProvider x:Name="routeProvider" 
                                           BingKey="Your Bing key here."
                                           RouteCalculated="routeProvider_RouteCalculated">
                    <dxm:BingRouteDataProvider.RouteOptions>
                        <dxm:BingRouteOptions Mode="Driving" 
                                              OptimizeWaypoints="True"/>
                    </dxm:BingRouteDataProvider.RouteOptions>
                </dxm:BingRouteDataProvider>
            </dxm:InformationLayer>
        </dxm:MapControl>
    </Grid>
</dx:ThemedWindow>
using DevExpress.Xpf.Core;
using DevExpress.Xpf.Map;
using System.Collections.Generic;
using System.Windows;

namespace WaypointOptimization {
    public partial class MainWindow : ThemedWindow {
        public MainWindow() {
            InitializeComponent();
        }
        private void ThemedWindow_Loaded(object sender, RoutedEventArgs e) {
            List<RouteWaypoint> waypoints = new List<RouteWaypoint>() {
                new RouteWaypoint("San Francisco", new GeoPoint( 37.4639, -122.2459)),
                new RouteWaypoint("Las Vegas", new GeoPoint( 36.1030, -115.0811)),
                new RouteWaypoint("San Jose", new GeoPoint( 37.20, -121.54)),
                new RouteWaypoint("Chico", new GeoPoint(39.4424, -121.508)),
                new RouteWaypoint("Los Angeles", new GeoPoint( 34.03, -118.15)),
                new RouteWaypoint("Oakland", new GeoPoint( 37.4816, -122.1615))
            };
            routeProvider.CalculateRoute(waypoints);
        }
        private void routeProvider_RouteCalculated(object sender, BingRouteCalculatedEventArgs e) {
            // Get waypoint indexes:
            int[] waypointsOrder = e.CalculationResult.RouteResults[0].WaypointsOrder;
            //...
        }
        private void OnDataRequestCompleted(object sender, RequestCompletedEventArgs e) {
            // Call the ZoomToFitLayerItems method to zoom the map so that it displays the whole generated route.
            mapControl.ZoomToFitLayerItems();
        }
    }
}
See Also