简体   繁体   中英

Google Maps API v3 geocoding OVER_QUERY_LIMIT

I have an application that needs to geocode a large number of addresses at a time (~1500). I'm using the Javascript Google Maps API Library v3 to retrieve the latitude and longitude, and the information is being stored in a MySQL database for later use.

Obviously this is taking a while.. My code puts the addresses into an array, then calls a recursive function on the array. The function takes each address and attempts to geocode it. If the geocode is successful, the function continues with the next address. If the geocode returns ZERO_RESULTS , the function continues with the next address. If the geocode returns OVER_QUERY_LIMIT , the function uses setTimeout to pause for a set amount of time (stored in var timeout , then retries again.

Now I've tried many different values for timeout , and they differ in how well they work.. The best was probably 2000 , or two seconds, and that allowed me to geocode around 365 addresses. However, once the program has coded around 250 addresses, it slows completely down, to the point where it is coding 1 address every 10 seconds..

So.. Does anyone know how to speed up this process? I also currently have a counter that checks how many times the function is called on the same address (to track how many OVER_QUERY_LIMIT errors are received before the address is coded). Should I perhaps delay for 2 seconds normally, and then if the same address receives OVER_QUERY_LIMIT 10 times, delay for 30 seconds or something?

Any help is much appreciated! Cheers

You can pay for higher limits or use a different geocoding provider.

I work at SmartyStreets, one such provider, where there's no request limits. LiveAddress scales up in the cloud. 1,500 addresses isn't much compared to the tens and hundreds of millions we are used to geocoding. I'll let you do your own research of course, but in case you're curious what it's like:

var addr = {
    street: "7584 E Big Canyon Dr.",
    zipcode: "92808"
};

// If you don't have the address in component form, you could just pass
// in a string containing the entire address instead.

LiveAddress.geocode(addr, function(geo) {
    alert("The address is at: " + geo.coords);
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM