BingRouteResult.WaypointsOrder Property
Returns an array of waypoint indexes.
Namespace: DevExpress.XtraMap
Assembly: DevExpress.XtraMap.v24.1.dll
NuGet Package: DevExpress.Win.Map
Declaration
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:
using DevExpress.XtraMap;
namespace MapOptimizePoints {
public partial class Form1 : Form {
string MyBingKey { get { return "Your Bing key here."; } }
public Form1() {
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e) {
// Create a background image layer:
ImageLayer imageLayer = new ImageLayer();
imageLayer.DataProvider = new BingMapDataProvider {
BingKey = MyBingKey,
Kind = BingMapKind.RoadLight
};
mapControl1.Layers.Add(imageLayer);
// Create an information layer to show route data from the Bing Maps service:
InformationLayer infoLayer = new InformationLayer();
mapControl1.Layers.Add(infoLayer);
// Create a route provider that obtains route data from the Bing Maps:
BingRouteDataProvider routeProvider = new BingRouteDataProvider();
routeProvider.BingKey = MyBingKey;
// Create a list of waypoints used to create a route:
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.RouteOptions.OptimizeWaypoints = true;
routeProvider.RouteOptions.Mode = BingTravelMode.Driving;
routeProvider.CalculateRoute(waypoints);
routeProvider.RouteCalculated += RouteProvider_RouteCalculated;
infoLayer.DataProvider = routeProvider;
infoLayer.DataRequestCompleted += OnDataRequestCompleted;
}
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) {
mapControl1.ZoomToFitLayerItems(0.4);
}
}
}
See Also