Google Maps Dircetions API - Arrival time?
Asked Answered
A

0

10

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

Asmodeus answered 14/4, 2016 at 8:29 Comment(9)
Check this SO question 1042885 and 10082122 if it can help you :)Rocket
Thank You! I have read those questions, but I have not found any information regarding the "arrival-time". (Only "departure time")Asmodeus
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? ThanksDickenson
Hi - I was not able to solve this problem with google. So my employer decided to use another API. developer.here.com With this API it is working very good, and the support is great. However it is expensive.Asmodeus
@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 stackexchangeBaluster
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.Firepower
Has this been updated?Chapple
Still the same...Cookie
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 to keep yourself updated if there are any changes in the API.Carrasquillo

© 2022 - 2024 — McMap. All rights reserved.