Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Optimal map routing with Google Maps

Tags:

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?

like image 246
Soldarnal Avatar asked Dec 03 '08 15:12

Soldarnal


People also ask

Can I Optimize route on Google Maps?

Google Maps actually has zero route optimization features, meaning you have to do all the calculations manually when you have multiple stops to make.

What is the most efficient route on Google Maps?

If you want to find the fastest route, you must manually reorder the stops until you see the shortest estimated time. To adjust the order, drag the three lines on the right-hand side of each stop and drop it in a different place. Then, compare the estimated time of arrival (ETA) of different routes.

How does Google Maps do routing?

You can draw a route on Google Maps that includes a driving, walking, or cycling route and save it or share it with others. To create a route, open "Your places" in the menu on Google Maps and then choose "Create Map" on the Maps tab.


1 Answers

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

like image 74
Geir Engdahl Avatar answered Oct 12 '22 04:10

Geir Engdahl