So I am working with V3 and I'm trying to calculation the driving time
between two points (latlng). I already have the distance and I can get
the driving time using the following code:
function getDrivingTime(start, end) {
var response;
var request = {
origin : start,
destination : end,
travelMode : google.maps.DirectionsTravelMode.DRIVING
};
directionsService.route(request, function(response, status) {
if (status == google.maps.DirectionsStatus.OK) {
alert(response.routes[0].legs[0].duration.text);
}
});
}
BUT there's no way to actually return a value within the route method.
You can't even assign values outside of it, so I have no way of
returning that string that has the driving time inside of it... I'd
like to do this:
function getDrivingTime(start, end) {
...
if (status == google.maps.DirectionsStatus.OK) {
return response.routes[0].legs[0].duration.text;
...
}
but it never returns a value. I'm so confused. How can I get the
driving time or duration using the GoogleMaps api?
--
You received this message because you are subscribed to the Google Groups
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-maps-js-api-v3?hl=en.