I use google 's distance matrix api to get the distance and time back like this
function calculateDistances() {
var service = new google.maps.DistanceMatrixService();
service.getDistanceMatrix(
{
origins: [from],
destinations: [to],
travelMode: google.maps.TravelMode.DRIVING,
unitSystem: google.maps.UnitSystem.METRIC,
avoidHighways: false,
avoidTolls: false
}, callback);
}
the callback gives me back the time and distance.
The problem i have sometimes if the distance is far the time comes back in hours but i always need minutes for a custom calculation method...
How can i fix this problem...
Please check the response object you will have two values text and value. Value property has the duration in seconds.
"duration" : {"text" : "19 hours 9 mins","value" : 68914}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With