> I'm trying to dynamically get the driving distances of many locations Beware that there are limits on how many and how fast you can request directions, to prevent abuse.
> This doesn't return anything and I can't set the values of any global > variables inside the "function (response, status)". Well, you can set them ... but its a matter of timing. The Directions service is asynchronous, calling it just fires off a request. Your function then immediately returns the unset 'distance'. Some time later, the Directions response comes back and your callback routine is executed, setting the value of 'distance'. But it's too late by then. As you've already noted, if you want to do something with the returned response, you must do it within the callback. -- 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.
