Thanks Rossko, I changed my code and now I've got it working the way I
want it to.  I'd read plenty of posts and documentation before I wrote
this one yet I still didn't uite grasp the concept of the callback
function, but your explanation cleared it up for me.  My updated
application, http://docksearch.net/caresearch/mapper.php is sorting
locations by distances the way I wanted it to.

As for the request limit, I think I can work around it.  Right now
it's refreshing a new list of locations and getting driving distances
for each one every single time a dragend event happens.  I can change
it so that it only adds new locations that appear as the map changes,
as opposed to refreshing the entire list every time.  In my testing, I
haven't run into any limits the way I have it now so I think with that
change I should be ok.

Larry, thanks for catching my error in IE.  I'm in the very early
stages of developing this app so I haven't really tested it across
browsers yet, thanks for catching my error.

I'm impressed with how quickly you guys responded and I really
appreciate the advice.  I saw your responses right away but wanted to
get everything working properly before I thanked you guys.

On Oct 4, 7:07 pm, "[email protected]" <[email protected]>
wrote:
> 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.

Reply via email to