Reputation: 500
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