简体   繁体   English

Google Maps API v3 地理编码 OVER_QUERY_LIMIT

[英]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).我有一个应用程序需要一次对大量地址进行地理编码(~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.我正在使用 Javascript Google Maps API Library v3 来检索纬度和经度,并将信息存储在 MySQL 数据库中以备后用。

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.如果地理编码返回ZERO_RESULTS ,则函数继续下一个地址。 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.如果地理编码返回OVER_QUERY_LIMIT ,则该函数使用setTimeout暂停一段时间(存储在var timeout ,然后再次重试。

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.现在我已经尝试了许多不同的timeout值,它们的工作效果不同。最好的可能是2000或两秒,这使我能够对大约 365 个地址进行地理编码。 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..然而,一旦程序编码了大约 250 个地址,它就会完全变慢,以至于每 10 秒编码 1 个地址。

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).我目前还有一个计数器,用于检查在同一地址上调用该函数的次数(以跟踪在地址编码之前收到了多少OVER_QUERY_LIMIT错误)。 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?我应该正常延迟2秒,然后如果同一个地址收到OVER_QUERY_LIMIT 10次​​,延迟30秒还是什么?

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.我在 SmartyStreets 工作,这是一家这样的提供商,那里没有请求限制。 LiveAddress scales up in the cloud. LiveAddress在云中扩展。 1,500 addresses isn't much compared to the tens and hundreds of millions we are used to geocoding.与我们习惯于进行地理编码的数以千万计的地址相比,1,500 个地址并不多。 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);
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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