0

This might sound weird, but is there a way to request multiple directions with only one call to the Directions API ?

I'm asking this because I need to calculate a lot of routes at the same time, and I recently saw this :

Free up to 2,500 requests per day. $0.50 USD / 1,000 additional requests, up to 100,000 daily, if billing is enabled.

2,500 requests per day seems to be ok, but as I said I need to calculate a LOT of routes at the same time (up to 50 I think), so 2,500 is way too small.

Here is why I need to calculate these routes:
I need to get multiple routes from multiple departures points but with the same arrival point (for example route from B to A, route from C to A etc), to find which route is faster (but I need to save all the routes). I am currently requesting every single route with AsyncTasks and it is working fine, but it costs too much requests.

Please share if you have any idea on how I could limit the number of requests, and thank you in advance

David Seroussi
  • 1,650
  • 2
  • 17
  • 34

1 Answers1

0

You may try to use the parameter alternatives, if it is set to true, it specifies that the Directions service may provide more than one route alternative in the response.

Here is example of request that use alternatives parameter

https://maps.googleapis.com/maps/api/directions/json?origin=Toronto&destination=Montreal&alternatives=true&key=YOUR_API_KEY

Just take note that providing route alternatives may increase the response time from the server.

For more information, you can check this SO questions:

Community
  • 1
  • 1
KENdi
  • 7,576
  • 2
  • 16
  • 31
  • Thanks for replying, but the parameter `alternatives` doesn't let me set a new origin – David Seroussi Jul 06 '16 at 10:46
  • check the answer [here](http://stackoverflow.com/questions/17796389/1-origin-multiple-destinations-same-google-map-v3-error-message), I think it will give you some idea – KENdi Jul 06 '16 at 10:57