How to get total driving distance with Google Maps API V3?

As per Leniel’s answer: var totalDistance = 0; var totalDuration = 0; var legs = directionsResult.routes[0].legs; for(var i=0; i<legs.length; ++i) { totalDistance += legs[i].distance.value; totalDuration += legs[i].duration.value; } $(‘#distance’).text(totalDistance); $(‘#duration’).text(totalDuration); Actually, this works just fine too, if you don’t have any waypoints: $(‘#distance’).text(directionsResult.routes[0].legs[0].distance.text); $(‘#duration’).text(directionsResult.routes[0].legs[0].duration.text); Here’s a fuller example using lodash. Shouldn’t be too hard to … Read more