Question

I am using the google maps api to get directions with the durationInTraffic option.

var request = {
    origin: start_address,
    destination: end_address,
    waypoints: waypts,
    durationInTraffic: true,
    optimizeWaypoints: true,
    travelMode: tmode
};

directionsService.route(request, function(response, status) { ....

This is working fine with a start and end address with no waypoints, as seen below:

Directions with Time in Current Traffic

My problem is that when i add a waypoint to to route then the "time in current traffic" estimate is no longer shown.

Is this a limitation of the API (I have found no documentation supporting that)? Or a possible fix / workaround as the traffic information is very important to my app.

Was it helpful?

Solution

I asked a similar question to the folks at Google about whether this was because I was using the stopover = true option in the waypoints and indeed it was. If you set it stopover to false, the duration in traffic should be returned.

There was small mention of this in the current documentation here

From Google:

... we can't predict how long you will stop at stopovers, making it difficult to give a proper estimation for the duration_in_traffic. By using non stopover waypoints you state that you wont stop at those waypoints, thus allowing our service to estimate the duration_in_traffic of every legs.

Also, they mentioned that if your using the Directions Matrix API, only origin/destination pairs count against your quota, so you can send multiple request without additional penalty.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top