Google Maps API V3 - How to Get Optimal Roundtrip Route Through Arbitrary Waypoints
dictionary, google-maps, google-maps-api-3
Solution
There is an "optimize" option in the V3 API. Have you tried it?
`optimizeWaypoints`
If set to true, the DirectionService will attempt to re-order the supplied
intermediate waypoints to minimize overall cost of the route. If waypoints
are optimized, inspect DirectionsRoute.waypoint_order in the response to
determine the new ordering.
optimizeWaypoints (optional) specifies that the route using the supplied
waypoints may be optimized to provide the shortest possible route.
First paragraph from https://developers.google.com/maps/documentation/javascript/reference.
Second from https://developers.google.com/maps/documentation/javascript/directions
Problem
There are many questions regarding Google Maps V3 API waypoints but none that address how to get optimal round trip route from a set of arbitrary waypoints. Basically, the order of weighpoints should be determined by whatever is the most optimum path and is not necessarily dictated by the order fed into the system. Does anybody know if this is even possible?