How to: Get Routes to the Destination Point Using the Bing Route Service
- 2 minutes to read
This example demonstrates how to calculate routes to the destination point from major roads using the BingRouteDataProvider.CalculateRoutesFromMajorRoads method.
Before route calculation, specify the destination point coordinates (GeoPoint.Latitude and GeoPoint.Longitude). In addition, you can specify the optional parameters: the destination name (RouteWaypoint.Description), driving or walking route travel mode using the BingRouteOptions.Mode property and route optimization options to calculate the optimal route either by time or by distance via the BingRouteOptions.RouteOptimization property.
To start the application, click the Calculate Routes From major Roads button, it handles the calculateRoutes_Click event. All parameters are passed to the CalculateMajorRoutes method, and you can see the results in the textblock element below and calculated routes on a map.
The requested results contain the total distance of a route, route leg, itinerary item (BingRouteResult.Distance, BingRouteLeg.Distance, BingItineraryItem.Distance), the time required to follow the calculated route (BingRouteResult.Time) and pass the route leg and itinerary item (BingRouteLeg.Time, BingItineraryItem.Time). You can also see the maneuver instructions associated with the itinerary item (BingItineraryItem.ManeuverInstruction) and other parameters.
Note that if you run this sample as is, you will get a warning message indicating that the specified Bing Maps key is invalid. To learn more about Bing Map keys, please refer to the How to: Get a Bing Maps Key tutorial.