On Oct 4, 3:21 pm, will <[email protected]> wrote: > Just read the guidelines for posting, right after I posted. Here's > what I'm working on:
http://docksearch.net/caresearch/mapper_1.php doesn't work in IE, extraneous comma at the end of the "hospital" object. (that doesn't solve you greater problem, which is the driving directions service is asynchronous, you _have_ to do everything you need to do with its results in the call back function. The service has a daily quota and a rate limit, so you may want to rethink your design. The usual suggestion is to do straight line distances, find the closest few ( pick a small number), calculate the driving distance to those). -- Larry > > If it's too complicated I can simplify it. > > On Oct 4, 6:12 pm, will <[email protected]> wrote: > > > > > I'm trying to dynamically get the driving distances of many locations > > with the following function: > > > function getDrivingDistance(location){ > > var distance; > > var request = { > > origin: startingPosition, > > destination: location, > > travelMode: google.maps.DirectionsTravelMode.DRIVING, > > unitSystem: google.maps.DirectionsUnitSystem.IMPERIAL > > }; > > directionsService.route(request, function (response, status) { > > if (status == google.maps.DirectionsStatus.OK) { > > > distance=response.routes[0].legs[0].distance.text; > > > } > > }); > > > return distance; > > > } > > > This doesn't return anything and I can't set the values of any global > > variables inside the "function (response, status)". I know it works > > because when I put somediv.setInnerHTML= distance it updates the DOM > > and shows distances, but I can't set any global variables inside that > > function. Does anyone know of a solution or any other way to return > > the driving distance between two points?- Hide quoted text - > > - Show quoted text - -- 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.
