On Apr 7, 10:46 am, TN <[email protected]> wrote: > Right now I'm creating a script that obtains the driving time duration > between two locations. the user will first put in a 5 digit zip code > and then the script compares to against zip codes in an array. An > example of what I intend to do with this is say there's 5 stores and > you want to find the closest one to a customer. I have everything set > up and the system gets the data perfectly fine except one detail > related to the speed of the program. > > I've set up a number of alert boxes to pop up so I can "walk" through > the program and know when something starts and when something ends. > When I walk through the program slowly all the data is returned > perfectly fine, but the issue comes up when i take off all the alerts > and let the script run as fast as it can which then causes the array > of stored times between the two locations is full of undefined or a > repeating duration time even though the array zip codes would be > states apart. > > I noticed that at the bottom left of my firefox (my test browser) that > there is the map.google.com showing up for a very short period which > is fine since I am calling the google api, but I believe that the time > it takes to return the data back is the issue. I did confirm this by > putting my alert boxes back into my code. And every time i compared a > new zip code against the user given I would quickly move through the > program (since I'm using alerts to walk through) before the "waiting > for maps.google.com" would finish and then I would notice that the > returned duration was either undefined or was the same as the last zip > code. > > I was curious if there was a small delay when calling upon the api > multiple times per second or is it simply put the lag of the > internet?
Geocoding and the directions service are asynchronous. They fire off a request to the server, your program keeps running, the answer comes back and the callback routine runs. Do you have a call back routine? -- Larry -- You received this message because you are subscribed to the Google Groups "Google Maps API V2" 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.
