9

I use the Google Directions API for calculating the needed time between 2 places. The API gives me an option departure_time, where I can pass the timestamp of the departure time (or "now"). Then the answer is the duration_in_traffic. This is working really great.

But I need to show the amount of time that the user needs with his car, when he want to be at his target at a specific time.

E.g. the user wants to be in Dortmund at 8pm (20:00). So I need to show him when he should start driving to arrive in time at his desired goal. The API-documentation says, that there is a parameter arrival_time, which does exactly what I need. Unfortunately they say it does only work for public-transport.

But Google maps itself offers the desired functionallity even for cars! As you can see in the screenshot: I said that I want to be in dortmund at 20:00 and google-maps says, I should start driving 'arround 18:30'

So how I can I achieve this with my app? Do I need another API or do I need to pass other parameters?

Here is my current API call:

https://maps.googleapis.com/maps/api/directions/json?origin=Bielefeld&destination=Dortmund&arrival_time=1460836800&key=AIzaxxxxxxxxxxxxxxxxxxxxxxxxxxx

best regards Michael

enter image description here

Michael B
  • 1,660
  • 3
  • 28
  • 59
  • 1
    Check this SO question [1042885](http://stackoverflow.com/questions/1042885/using-google-maps-api-to-get-travel-time-data) and [10082122](http://stackoverflow.com/questions/10082122/api-for-travel-times-including-traffic) if it can help you :) – KENdi Apr 15 '16 at 03:39
  • Thank You! I have read those questions, but I have not found any information regarding the "arrival-time". (Only "departure time") – Michael B Apr 19 '16 at 09:32
  • Hi Michael, have you found any solution for this? I need to implement the same functionality but I don't know how to get the duration_in_traffic? Thanks – Cristian Jan 12 '17 at 15:03
  • 1
    Hi - I was not able to solve this problem with google. So my employer decided to use another API. https://developer.here.com/ With this API it is working very good, and the support is great. However it is expensive. – Michael B Jan 12 '17 at 17:00
  • @MichaelB, could you elaborate on how you solved the problem via the HERE API? I've delved into it but found for the "arrival" parameter quote:"Note: You can only use this parameter when mode is set to publicTransportTimeTable" Posed a similar question [on GIS stackexchange](https://gis.stackexchange.com/questions/301702/getting-the-departure-time-based-on-a-desired-arrival-time-for-driving) – LMB Nov 08 '18 at 16:03
  • As far as I can tell, this info is still not possible to get via the API today, unfortunately. Only for Transit options (like Bus, Train) does the API allow `arrivalTime` to be set. – Mark Feb 25 '19 at 23:23
  • 1
    Has this been updated? – GenesRus Dec 10 '19 at 00:06
  • Still the same... – Mario Taddei Feb 23 '22 at 16:57
  • The documentation still states that the arrival_time parameter is only available when the travel mode is "transit". It does not work for driving mode nor when you do not specify a travel mode (which defaults to driving). There is currently an existing feature request in the Google Issue Tracker about making `arrival_time` available on "driving" mode in Directions API to get the `duration_in_traffic`. You can view and star it [here](https://issuetracker.google.com/35829984) to keep yourself updated if there are any changes in the API. – Yrll Nov 22 '22 at 23:49

0 Answers0