BingRouteDataProvider.RouteCalculated Event
In This Article
Occurs when a route has been calculated.
Namespace: DevExpress.XtraMap
Assembly: DevExpress.XtraMap.v25.1.dll
NuGet Package: DevExpress.Win.Map
#Declaration
public event BingRouteCalculatedEventHandler RouteCalculated
#Event Data
The RouteCalculated event's data class is BingRouteCalculatedEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
Calculation |
Returns a result of a route calculation. |
Cancelled |
Gets a value indicating whether an asynchronous operation has been canceled.
Inherited from Async |
Error |
Gets a value indicating which error occurred during an asynchronous operation.
Inherited from Async |
User |
Gets the unique identifier for the asynchronous task.
Inherited from Async |
The event data class exposes the following methods:
Method | Description |
---|---|
Raise |
Raises a user-supplied exception if an asynchronous operation failed.
Inherited from Async |
#Example
private void OnRouteCalculated(object sender, BingRouteCalculatedEventArgs e) {
RouteCalculationResult result = e.CalculationResult;
if((result.RouteResults == null) ||
(result.ResultCode == RequestResultCode.BadRequest)) {
rtbResults.Text = "The Bing Route service does not work for this location.";
return;
}
StringBuilder resultList = new StringBuilder("");
if(result.IntermediatePoints != null) {
resultList.Append(String.Format("_________________________\n"));
for(int i = 0; i < e.CalculationResult.IntermediatePoints.Count; i++)
resultList.Append(
String.Format("Starting point {0}: {1} ({2})\n",
i + 1,
e.CalculationResult.IntermediatePoints[i].Description,
e.CalculationResult.IntermediatePoints[i].Location)
);
}
if((result.RouteResults != null) & (result.ResultCode == RequestResultCode.Success)) {
for(int rnum = 0; rnum < e.CalculationResult.RouteResults.Count; rnum++) {
resultList.Append(String.Format("_________________________\n"));
resultList.Append(String.Format("Path {0}:\n", rnum + 1));
resultList.Append(String.Format(
"Distance: {0}\n",
e.CalculationResult.RouteResults[rnum].Distance
));
resultList.Append(String.Format(
"Time: {0}\n",
e.CalculationResult.RouteResults[0].Time
));
if(e.CalculationResult.RouteResults[rnum].Legs != null) {
int legNum = 1;
foreach(BingRouteLeg leg in e.CalculationResult.RouteResults[rnum].Legs) {
resultList.Append(String.Format("\tLeg {0}:\n", legNum++));
resultList.Append(String.Format("\tDistance: {0}\n", leg.Distance));
resultList.Append(String.Format("\tTime: {0}\n", leg.Time));
if(leg.Itinerary != null) {
foreach(BingItineraryItem itineraryItem in leg.Itinerary) {
resultList.Append(String.Format(itineraryItem.Maneuver + "\n"));
resultList.Append(String.Format(
"\t\tLocation: {0}\n",
itineraryItem.Location
));
}
}
}
}
}
}
rtbResults.Text = resultList.ToString();
}
See Also