Scarnet
Scarnet

Reputation: 500

Google Directions Javascript API Doesn't Return Duration_In_Traffic

I'm trying to use google direction JavaScript API to estimate a trip duration in traffic but for some way it's not returned as a part of the JSON array anyway here's how I call the service

        ser.route(
        {
            'origin': Markers[0].position,
            'destination': Markers[Markers.length - 1].position,
            'waypoints': wayPoints,
            'travelMode': google.maps.DirectionsTravelMode.DRIVING,
            'provideRouteAlternatives': true,
            drivingOptions: {
                departureTime: new Date (Date.Now),
                trafficModel: google.maps.TrafficModel.BEST_GUESS
            }

but when I try to get the duration in traffic this way

var minutes = element.legs[0].duration_in_traffic.value;

firebug returns

element.legs[0].duration_in_traffic is undefined

I'm pretty sure the region is traffic supported but I can't know why the duration in traffic isn't returned

Upvotes: 4

Views: 1215

Answers (1)

Jay
Jay

Reputation: 4007

This problem appears to be limited to the javascript client. You can make a GET request to the Directions API from your browser as described in my answer here.

Upvotes: 1

Related Questions