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
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 .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.