Hi Daniel quick reply: setTimeout - you are on the right track. Javascript has no actual 'wait for x', but you can use setTimeout to delay the running of a function. Essentially you use setTimeout to run the first request. Within that request, after you get the okay, you again use setTimeout to delay the start of the next request. If you put the request/result/status=ok block in a function, setTimeout is recursively calling that function each time. I've seen this suggested a number of times, both by Mike Williams in his great set of tutorials, and by Pamela Fox, a very helpful Google person (in a blog item she made, but I'm sorry I can't remember where exactly that was) I'm using that method myself, in something similar, but I'm not convinced that it is the most elegant or even foolproof method - the best it does is set a delay of however long you think is long enough to ensure a request is fullfilled. But I notice that (here in NZ) network traffic sometimes seems to slow things to over the timeout suggestions I've seen (300 - 500 ms), and I am now using 1 second as my delay, but still occasionally results appear to take longer than that. ...stu
On Oct 19, 1:34 pm, Daniel <[email protected]> wrote: > Thank you for both of your replies. I have been searching for quite > some time after Rossko's suggestion directing me to search the group > for 'multiple routes'. I came to the same conclusion as what you have > stated Stu, however I do not know how to 'wait for a result' before > proceeding. Is there something I am missing? I have looked into the > javascript setTimeout() function but that does not appear to be > helping. Is there something I should be looking to use in order to > ensure the result has been received? I apologise but unfortunately I > do not have a url for the project (it hasn't been published). > > Thanks for your help. > > Regards, > Daniel > > On Oct 19, 10:06 am, stu <[email protected]> wrote: > > > Hi > > you are probably going to have to supply a url with a (non)-working > > example if you want too much help, but I'd guess from your description > > that you are not taking account of the fact that route requests are > > asynchronous, so you might be looking for the result *before* the > > result has been returned. > > A quick look at your code seems to confirm that you are not doing a > > 'wait for result' before generating the next request. > > That might be enough to get you on the right track. > > ...stu > > > On Oct 18, 4:23 pm, Daniel <[email protected]> wrote: > > > > Hello there, > > > > I am currently having a problem when calculating multiple routes. What > > > I am try to do is:- 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.
