views:

85

answers:

1

In the Google Maps API, multiple calls to google.maps.ClientGeocoder.getLatLng(address, callback) are not guaranteed to finish in any order. What is an elegant way to determine all addresses have been geocoded, given an array of addresses?

Should I just count down based on the length of the array and execute code in the callback only if the countdown reaches zero, or is there a better way to do this in the Google Maps API?

Thanks

+3  A: 

If you are not doing special case processing for each lat lng response (ie just doing something when they have all come back), I don't see a downside with your counting down solution.

Cannonade