1

I've had success getting current travel time from location A to location B with API calls -- for example doing something like this:

https://maps.googleapis.com/maps/api/distancematrix/xml?units=imperial&traffic_model=best_guess&departure_time=now&origins=San+Bernardino,CA&destinations=Irvine,CA&key=xx

But what I'm wondering is if it's possible to make the same call pegged to a specific route. i.e. When Google gives you three options from A to B in the web interface, and you pick one, i.e. like this:

https://www.google.com/maps/dir/new+york+ny/brooklyn+ny/@40.6954797,-73.9936332,14z/data=!4m15!4m14!1m5!1m1!1s0x89c24fa5d33f083b:0xc80b8f06e177fe62!2m2!1d-74.0059413!2d40.7127837!1m5!1m1!1s0x89c24416947c2109:0x82765c7404007886!2m2!1d-73.9441579!2d40.6781784!3e0!5i1

It gives it a unique data tag (the string beginning with "!4m"). I'm wondering if it's possible to specify that data tag in an API call.

Any thoughts? Much appreciated.

Gabe
  • 11
  • 1
  • Interesting question, but you would need 2 things: A) a different form of the service that would return several possible routes, and B) a way for you to select one programmatically (based on what logic?). That service does not do that. Or Maybe what you want instead is a way to specify waypoints? Ie "I want distance from A to B via C,D,E...". Edit: maybe [this](http://stackoverflow.com/a/28702411/6730571) would help? – Hugues M. May 13 '17 at 10:00
  • Thanks Hugues -- while selecting the route programmatically would be useful for this type of problem in general, I don't explicitly need to do that, since I'll be working in low enough volume that I'll prefer to use the web interface to look up the data tag for the route I need. My volume will come from a large number of times of day, rather than a large number of routes. – Gabe May 15 '17 at 13:51

1 Answers1

0

The Google Maps Directions API allows you to set waypoints for your route and it also gives you the duration in traffic. If you set enough waypoints, you'll probably get the same route in the response of the API.

arbitrax
  • 1
  • 1