API returning un-optimized route despite being told to - Bing Maps API AJAX Controls V 7
-
Sunday, September 16, 2012 8:39 PM
Hi there,
I'm making a web application which shows 25 waypoints using Bing Maps AJAX V7.
The problem is, when I render the map, the route which I get back on the map is not optimized. at. all.
For example, see this link:
on this route, I can change the order and make my route optimal. But I'm trying to "get back" an optimum route from Bing Maps, which re-orders the way points, by itself and comes up with a optimum route, based on time or distance.
I'm using the following lines for optimization in my code.
directionsManager.setRequestOptions({ routeMode: Microsoft.Maps.Directions.RouteMode.driving,routeOptimization:Microsoft.Maps.Directions.RouteOptimization.shortestDistance});
Clearly, here, I'm passing a route optimization parameter.
So far, the question is, Bing is not giving back an optimized route regardless of passing a route optimization parameter or not.
Wait, you must be thinking, I have to make a calculateDirections() methods call on directionsManager everytime I add another waypoint? Which I probably am not making?
No. I tried that, I even did this.
//1. for waypiont in my waypoints
//2. add waypoint
//3. setRequestOptions{ route optimization params }
//4. calculate directions
//5. end
My question is, how can I add waypoints to a directionsManager object, then set request options as optimize the route for shortest distance, and get back, a rendered map from bing, which has re ordered all the way points for optimized distance.
Is this possible with bing maps API?
OR, I have to calculate shortest paths between individual points, order them accordingly and send them to bing?
- Edited by osmanehmad Sunday, September 16, 2012 8:40 PM
All Replies
-
Monday, September 17, 2012 7:51 AMOwner
You are confused on what Bing Maps does to optimize routes. The routing service will optimize the route based on distance between the waypoints in the order you provide them. It will not reorder your waypoints for you. If you want an API that reorders the points take a look at RouteSavvy which is built on top of the Bing Maps Routing service: http://www.onterrasystems.com/route-planning-routesavvy/http://rbrundritt.wordpress.com
- Proposed As Answer by Richard_BrundrittMicrosoft Employee, Owner Monday, September 17, 2012 7:52 AM
- Marked As Answer by Richard_BrundrittMicrosoft Employee, Owner Monday, October 01, 2012 1:43 PM
-
Wednesday, October 03, 2012 11:59 PM
Hello,
After getting the route in the map can i retrive the coordinates in the optimal sequence ?
I can draw the path with the pushpin ids, but i cant retrive the coordinates in a optimal sequence.
The example LINK:
Thanks
-
Thursday, October 04, 2012 9:36 AMOwnerYou have two options. The first is to make use of a the service here: http://www.onterrasystems.com/route-planning-routesavvy/ which will optimize using the traveling sales men algorithm. The second option is to make use of the Windows 8 Code sample found here:http://code.msdn.microsoft.com/Bing-Maps-trip-optimizer-c4e037f7
http://rbrundritt.wordpress.com

