On Mar 26, 11:49 am, Li Li <[email protected]> wrote:
> I have 20 ATM position in a city.
> The user will choose the start point by the zip code,Google map will
> show the the route to the nearest ATM.
>
> now, I could calculate (by the getDistance method) user's zip code
> postion to each ATM one by one, that means loop 20times, then choose
> the nearest, but it too slowly and inefficient.

What are you asking? Are you asking to choose the nearest ATM, or the
shortest route to visit all the ATMs?

If the nearest ATM because you just want some cash, then you are going
to have to examine each distance to see which is the shortest. You
could cut down the number of directions calls by limiting the ATMs you
calculate to those within a certain straight-line distance. Example:
you have 20 ATMs and you want to find the shortest route to any one of
them -- it doesn't matter which. Select the five which are closest and
analyse the route to each of those. You might even get away with
analysing routes to two or three of them, especially if you're
walking.

If you want the shortest route between all the ATMs, perhaps because
you're delivering cash to them, it's the Travelling Salesman Problem
and searching for that will find some resources.

Andrew
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to