|Translate this page:|
Google Maps API Tutorial© 2006, 2007, 2008, 2009 Mike Williams
Geocoding multiple addressesIf you've got lots of addresses to geocode, then you can't just write a loop that calls the getAddress() function in the previous example several times. There are several problems:
The goeocoder quota is now set at 15,000 geocode calls per IP address per day. The old 1.725 second speed limit per API key no longer applies, but there's a mysterious "limit to the maximum rate" mentioned here and here. At the time of writing, it seems that a 100ms delay between geocode requests works well for long runs. Shorter delays case more 620 errors and may take longer to complete the retries.
If you use .getLatLng() for geocoding multiple addresses, then you won't be able to recognise the 620 errors. I recommend using .getLocations() so that you can monitor the 620 errors. If you decide to use .getlatLng(), then I suggest using a considerably longer delay.
In my example, I start with a 100ms delay and increase the length of the delay each time I retry an address due to receiving a 620 error.
In my example, the list of target addresses is hard coded, but you could read the list from one XML file, pass forward all the attributes to your getAddress() function and include all the details in your output.
If you can run server-side scripting on your webserver, then you could send each result to your server to be stored in your database, but in that case you'd probably find it easier to use a non-Google batch geocoder that you could call directly from your server.