BingRouteIsochroneDataProvider.CalculateIsochroneByTimeWithTraffic(RouteWaypoint, Int32, DateTime) Method
Calculates a time-based isochrone based on traffic information for the specified point in time.
Namespace: DevExpress.XtraMap
Assembly: DevExpress.XtraMap.v24.2.dll
Declaration
public void CalculateIsochroneByTimeWithTraffic(
RouteWaypoint waypoint,
int maxTime,
DateTime dateTime
)
Parameters
Name | Type | Description |
---|---|---|
waypoint | RouteWaypoint | Specifies an origin point’s coordinates. |
maxTime | Int32 | Specifies the maximum travel time in which the isochrone polygon is calculated. The default measurement unit is second. Use the BingRouteIsochroneOptions.TimeUnit property to define the measurement unit. |
dateTime | DateTime | Specifies a point in time used to obtain the current or predictive traffic information. |
Remarks
You can specify the following parameters to calculate a time-based isochrone:
Example
The following code plots a polygon that shows the area that is accessible from the specified point. The size of the area depends on a given travel time (the time is equal to 10 minutes in the example below):
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 the CalculateIsochroneByTimeWithTraffic method to calculate an isochrone.
using DevExpress.XtraMap;
using System;
using System.Windows.Forms;
namespace IsochroneSample {
public partial class Form1 : Form {
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 key.";
GeoPoint origin = new GeoPoint(36.1532403246368, -86.7701703811725);
mapControl1.CenterPoint = origin;
isochroneDataProvider.IsochroneOptions.TimeUnit = TimeMeasureUnit.Minute;
isochroneDataProvider.IsochroneOptions.Mode = BingTravelMode.Driving;
isochroneDataProvider.CalculateIsochroneByTimeWithTraffic(new RouteWaypoint("", origin), 10, new DateTime(2021, 05, 05, 15, 0, 0));
infoLayer.DataProvider = isochroneDataProvider;
infoLayer.DataRequestCompleted += OnDataRequestCompleted;
}
private void OnDataRequestCompleted(object sender, RequestCompletedEventArgs e) {
// Call the ZoomToFitLayerItems method to zoom the map so that it displays the created isochrone.
mapControl1.ZoomToFitLayerItems();
}
}
}