Google maps API using arrival time with traffic duration - json

The Google Maps API docs as well as all questions I have found on Stack Overflow all state that departure time must be included to return traffic duration. However, my application requires the use of arrival time and not departure time.
The docs state that one can pass either departure or arrival time, but this is not mentioned in relation to duration_in_traffic. Is it possible to pass arrival time instead of departure time and still receive the duration_in_traffic? Maps itself does this, I don't see a reason for Google's API to be any different.

This is not currently possible, but there is a long-standing feature request to have this feature added. You can star the issue to receive updates and show Google that there is additional interest.

Related

Bus Stop Schedule

I'm having some trouble retrieving some information about the bus stop schedule of a single bus stop.
Basically, when I open the bus stop on google maps, I can see all bus lines for that stop and it's respective schedule time.
After clicking on see departure board:
However, I couldn't find a way of getting this information from the google maps api.
I tried searches by place_id and geographic coordinates and I was able to find some information about this stop, but not lines or schedule times..
I saw some people being able to find some information like this by setting a route on the directions API, but in my case I need the complete schedule of the bus stop itself, and not the info between two locations.
I'm afraid Google doesn't expose this sort of information via their Google Maps APIs at the moment. There is a feature request in the Google issue tracker to make this information available (33 stars currently, however doesn't look like priority at Google as FR was opened in 2015):
https://issuetracker.google.com/issues/35827961
Feel free to star the feature request to add your vote and subscribe to further notifications from Google.

Google Maps Transit Directions URL with Arrival Time without using API

I'm building a Google MAPs URL to launch in a new tab, and I'd like to specify Arrival Time for Transit directions. I am not using the API, just the basic URL options outlined here.
It makes no mention of being able to specify arrival time. Some older posts do mention this for platform-specific cases, e.g. here for iOS, but they are using a very different looking URL format to what is outlined in the link above.
I know specifying Arrival Time requires you specify mode as transit, which I'm doing.
As an example, the following URL will bring up transit directions from 30 Rock in New York to the Metropolitan Museum of Art:
https://www.google.com/maps/dir/?api=1&origin=30+Rockefeller+Plaza%2C+New+York%2C+NY+10112%2C+USA&destination=1000+5th+Ave%2C+New+York%2C+NY+10028%2C+USA&travelmode=transit
Without using the actual Google Maps API and all that entails (API Key, proxy server for security, paying per use), is there a modification to that URL that would allow me to specify an arrival date and time? I tried appending &ttype=arr&date=05/13&time=08:00 as shown in the previous post I linked, but that did not help.
I would suggest to file for a Feature Request regarding this in our Google Issue Tracker [1].
Issue Tracker is a tool used internally at Google to track bugs and feature requests during product development. It is available outside of Google for use by external public and partner users who need to collaborate with Google teams on specific projects. You can learn more here [2].
[1] - https://issuetracker.google.com
[2] - https://developers.google.com/issue-tracker/

API - Travel time based on arrival time

I want to find a travel time (including traffic) between two addresses.
Inputs - origin, destination, arrival time, mode of transportation, traffic model (pessimistic, optimistic, best guess)
Output - Travel time
It looks like the Google Distance Matrix API is the API I should be using for this except that I am not able to add an input of arrival time for driving. I am prompted to add a departure time. When the transportation mode is transit I am able to enter an arrival time.
Is this a limitation of the distance matrix API? Is there a paid for version or another work around for this?
As of today (January 6, 2019) arrival time for driving is not supported. Here is the relevant portion of the help file for the API's directions method:
:param arrival_time: Specifies the desired time of arrival for transit
directions. Note: you can't specify both departure_time and
arrival_time.
:type arrival_time: int or datetime.datetime
The key being that arrival time is only used for transit directions and not driving directions. When I use mode='driving' and an arrival_time, I get and error that ends with:
raise googlemaps.exceptions.HTTPError(response.status_code)
googlemaps.exceptions.HTTPError: HTTP Error: 400
When I change this to a departure_time, the function call works just fine.
Explicit answers to the questions:
Is this a limitation of the distance matrix API?
Yes.
Is there a paid for version or another work around for this?
No. Your only option is call the API with a guess for the departure time, find the travel time and then iterate until the arrival time converges.
instead of using the google direction matrix try to use google map direction API, it will give you best results with the time distance and traffic update, see GOOGLE MAP DIRECTIONS API docs.
You need to use the Google map distance matrix API, which get input as source latitude, longitude and destination latitude, longitude. It will return the json file contains the source address, destination address, distance in km and time with traffic and without traffic.Below is link follow it
https://developers.google.com/maps/documentation/distance-matrix/intro
There is also a limit of this API, it allows only 2500 hits per day

Google Maps Dircetions API - Arrival time?

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

When will future "departure_time" for "driving direction" be available?

My company is looking for map API that supports driving route and time inquiries for future trips, e.g. getting a best route for a trip tomorrow at noon. A closer prediction would be use historical average traffic to generate such a route.
I thought Google Maps would have such capability, but it doesn't seem that they do, according to the description on their website:
"For driving directions: Google Maps API for Work customers can specify the departure_time to receive trip duration considering current traffic conditions. The departure_time must be set to within a few minutes of the current time."
So my question is: why Google is not doing general departure_time based inquiries at the moment? Is Google planning to offer the service in future? If so, when?
Thanks!
You can submit a feature request at Google Maps Issue Tracker