BingRouteIsochroneDataProvider Class
Allows you to use the Bing Maps service to calculate an isochrone and display it on the map. An isochrone shows an area reachable from a specific location.
Namespace: DevExpress.XtraMap
Assembly: DevExpress.XtraMap.v24.2.dll
Declaration
Remarks
Follow the steps below to calculate a route isochrone:
Create an InformationLayer object and add it to the MapControl.Layers collection.
Initialize the layer’s InformationLayer.DataProvider property with a BingRouteIsochroneDataProvider object.
Specify the provider’s BingKey property.
Call one of the following methods to calculate an isochrone:
Use the IsochroneOptions property to define parameters that are applied when the isochrone is calculated (for example, travel mode, distance measurement unit, and time measurement unit).
You can also handle the IsochroneCalculated event to customize the appearance of the polygon that the BingRouteIsochroneDataProvider generates.
Example
The following code plots a polygon that shows an area accessible from the specified point:
using DevExpress.XtraMap;
using System;
using System.Drawing;
using System.Windows.Forms;
private void Form1_Load(object sender, EventArgs e) {
ImageLayer imageLayer = new ImageLayer();
mapControl1.Layers.Add(imageLayer);
BingMapDataProvider provider = new BingMapDataProvider();
provider.BingKey = "Insert your Bing key.";
provider.Kind = BingMapKind.RoadLight;
imageLayer.DataProvider = provider;
InformationLayer infoLayer = new InformationLayer();
mapControl1.Layers.Add(infoLayer);
BingRouteIsochroneDataProvider isochroneDataProvider = new BingRouteIsochroneDataProvider();
isochroneDataProvider.BingKey = "Insert your Bing Maps key.";
GeoPoint origin = new GeoPoint(36.1532403246368, -86.7701703811725);
mapControl1.CenterPoint = origin;
isochroneDataProvider.CalculateIsochroneByDistance(new RouteWaypoint("", origin), 10);
isochroneDataProvider.GenerateLayerItems = false;
isochroneDataProvider.IsochroneCalculated += IsochroneCalculated;
infoLayer.DataProvider = isochroneDataProvider;
}
private void IsochroneCalculated(object sender, BingRouteIsochroneCalculatedEventArgs e) {
foreach (var polygon in e.CalculationResult.IsochroneResult.Polygons) {
MapPolyline item = new MapPolyline();
foreach (var points in polygon.Coordinates)
item.Points.Add(points);
item.StrokeWidth = 4;
item.Stroke = Color.Red;
VectorItemsLayer vectorLayer = new VectorItemsLayer();
mapControl1.Layers.Add(vectorLayer);
MapItemStorage storage = new MapItemStorage();
vectorLayer.Data = storage;
storage.Items.Add(item);
}
mapControl1.ZoomToFitLayerItems();
}