On Jan 23, 3:55 pm, Saad Alothman <[email protected]> wrote: > hello all > i am trying to locate the distance between a single cutomer and all > the branches, this is the code i have tried but it gives the same > result with every branch eventhough the function gdir.load is called > every time in the loop (called from setDirections fucntion).
It would appear that gdir is a global variable, or at least it's reused for every directions request. Have you read the last paragraph of the .load documentation? http://code.google.com/apis/maps/documentation/reference.html#GDirections.load Note also that GDirections is asynchronous, so all you are doing is firing off several requests. Your .getDistance() call is processed before any of the results are returned -- which is why they are all the same. Your variable gdir isn't updated before the loop finishes. In order to use the results, you need to handle the directions' load event. It's impossible to see whether you're doing that, but I suspect you're not. > and below is a snippit i hope it shows what i mean A link would be better, which is why the posting guidelines ask for that. http://groups.google.com/group/google-maps-api/web/why-including-a-link-is-critical 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.
