2

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?

Matt
  • 1,017
  • 2
  • 11
  • 27

3 Answers3

0

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.

Finncent Price
  • 543
  • 1
  • 8
  • 20
-2

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.

  • How will this answer solves the issue that the user is facing? – Coder Mar 15 '17 at 14:20
  • google map direction API provides the direction as well as the duration of time with different routes a well as on basis of traffic analysis. so you will get your travel time as per you required on the basis of live traffic. – Harshdeep singh Mar 16 '17 at 05:02
  • He doesn't want to `retrieve` the arrival time but he intends to `give it in input to API` – Coder Mar 16 '17 at 05:10
  • I am not getting buddy what do you want to do, please clarify your question. – Harshdeep singh Mar 16 '17 at 05:31
  • It's not my question. I was explaining the question to you as you got it wrong. – Coder Mar 16 '17 at 21:13
-2

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

  • 2
    The question states that the Google distance Matrix API does not allow for mode=driving and using an arrival time. Thus your answer does not answer the question. I happen to be facing the same question. – LMB Nov 07 '18 at 15:10