So, I'm just learning javascript to communicate with the Google Maps API. I was wondering if anyone has an elegant solution to this problem that I am facing.
A Google Maps route request should contain three things (origin, destination, and travelMode). My TravelMode will always be TRAFFIC. The origin will always be where the user is.
The purpose, however, must be changed. I have several waypoints, and the user will visit and would like to provide the shortest possible trip depending on which route points are selected and where the user is, ending the route on one of the waypoints (for example: ABC or ACB, but always Axx. ..J).
Is there any possible way to do this differently than to calculate all the possible paths and see that it has the shortest distance (or time, or what I am evaluating)? It seems like it would be prohibitively expensive (O (n!)).
edit: with optimizeWaypoints set to true, this becomes an O (n) problem instead of O (n!), but now I am having problems issuing too many requests in too short a period of time.
source
share