hello Andrew and thank you for your reply..

i apologies for not posting a link and posted the code instead.

well if you mean that i should call Gdirections.load() method every
time inside the loop, then this is done by the method setDirections,

this is the full code in a link

note that you need the last bit for the php to make it process and
pass values to JavaScript, that variable represents the customer
postcode

http://stuiis.cms.gre.ac.uk/as924/project/pizza/testgmap6.php?cpc=e149rt

i appreciate your help...


On 23 Jan, 16:15, Andrew Leach <[email protected]> wrote:
> 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#GDirect...
>
> 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-li...
>
> 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