thank you very much for your advice, I am too eager to accomplish the
basic function of my code. Some conditions like status != 'OK' is not
taken into cosideration currently...I would complet these after.
But the "data" here is not the same in my code, where the address data
is passed by another function, so it's dynamic rather than static. I
am wandering how can I pre-geocode these address before I use the
their locations in adding markers.
>
https://groups.google.com/d/topic/google-maps-js-api-v3/GP4tZLPt_vc/d...
> The function called in your for loop (getCoordinates) is then calling the
> geocoder and returning immediately to the for loop, because the call to the
> geocoder is an asynchronous call with a callback function. The browser
> isn't going to wait for the geocoder call to be completed before moving on.
>
> In general it's a bad practice to use the Javascript geocoder in a loop like
> this. Depending on how many locations are in your array, you could quickly
> send too many requests over a very short period of time, and Google will
> start rejecting requests. You're better off geocoding your locations in
> advance with the web services geocoder, then using the Javascript APIs to
> display those locations using lat/lng values.
>
> I didn't see any checks in your callback function for when status != 'OK'.
> My guess is that you're getting rejections but don't know because you're
> not checking:
http://code.google.com/apis/maps/documentation/javascript/services.ht...