I was hoping I would be able to pass off a list of addresses via XML or something, but from the reading I've done that doesn't look likely.
What you suggested would definitely get rid of some overhead. It would avoid loading the map_canvas every time and only load it for the last 5-15 or whatever I choose addresses. I'll throw together that javascript eventually and come back with the performance results. On May 4, 12:27 pm, "[email protected]" <[email protected]> wrote: > On May 4, 10:12 am, Justin <[email protected]> wrote: > > > I was wondering if there is a moreefficientway for me to go about > > calculating the shortest distance between two locations. I am running > > a search based upon what the user types into the web form, and then > > looping through all the addresses in my datastore. > > > Is there a moreefficientway to get the shortest distance between two > > locations rather than hitting Google X amount of times (where X is > > equal to the number of addresses in my datastore). > > You could try limiting the GDirections calls to the closest 5-15 > points where closest is the straight line distance (calculated with > Haversine or GLatLng.distanceFrom() depending on whether it is > calculated on the server or the client) > > -- Larry > > > > > Here is how I am currently doing it: > > > 1. I have a gDirections object, which gets loaded with the address > > the user typed in, and the first address from the datastore. > > > 2. Once the directions are loaded, I check the distance between those > > two points by calling the getDistance().meters function. > > > 3. I store the distance, and continue looping through all the > > addresses in the datastore and loading the directions time after > > time. I check to see if the distance is shorter, and if so then I > > store the address so I know that that is the shortest address. > > > If you need clarification, feel free to ask. I just feel like there > > is a lot of overhead on this application, and I'd like to make it a > > little moreefficient. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Maps API" 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-API?hl=en -~----------~----~----~----~------~----~------~--~---
