Search code examples
google-mapstraveling-salesman

Optimal map routing with Google Maps


Is there a way using the Google Maps API to get back an "optimized" route given a set of waypoints (in other words, a "good-enough" solution to the traveling salesman problem), or does it always return the route with the points in the specified order?


Solution

  • There is an option in Google Maps API DirectionsRequest called optimizeWaypoints, which should do what you want. This can only handle up to 8 waypoints, though.

    Alternatively, there is an open source (MIT license) library that you can use with the Google Maps API to get an optimal (up to 15 locations) or pretty close to optimal (up to 100 locations) route.

    See http://code.google.com/p/google-maps-tsp-solver/

    You can see the library in action at www.optimap.net