This thread is worth a read: 
 https://groups.google.com/d/topic/google-maps-js-api-v3/GP4tZLPt_vc/discussion
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.html#GeocodingStatusCodes

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-maps-js-api-v3/-/NlLEYhwmFt0J.
To post to this group, send email to google-maps-js-api-v3@googlegroups.com.
To unsubscribe from this group, send email to 
google-maps-js-api-v3+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply via email to