javascript - OVER_QUERY_LIMIT 谷歌地理编码
问题描述
我知道有很多关于此的问题,但我找不到可以回答我的具体问题的问题。
有人能看出这有什么根本性的问题吗(很可能是/必须是!)?据我了解,Google Geocode API 的每秒限制是每秒 50 个请求。我正在运行以下代码,只有大约 80 个地址,大约 15 个地址后它会引发 OVER_QUERY_LIMIT 错误。15 个请求不是在 1 秒内发出的,为什么我会得到 OVER_QUERY_LIMIT?
我设置了间隔,因为我遇到了问题。我对这个间隔的理解是它应该将每秒查询数限制为 4(远小于 50)。但我仍然面临这个问题!
var done = true;
function geocodeAddress(address, geocoder, resultsMap) {
done = false;
geocoder.geocode({"address": address}, function(results, status) {
if (status === "OK") {
var marker = new google.maps.Marker({
map: resultsMap,
position: results[0].geometry.location
});
} else {
console.error("Geocode on '" + address + "' was not successful for the following reason: ");
console.log(status);
}
done = true;
});
}
function geocodeAll(addresses) {
var addressCount = addresses.length;
var counter = 0;
var next = setInterval(function() {
console.log(counter);
if(done) {
geocodeAddress(addresses[counter], geocoder, map);
counter++;
}
if(!(counter < addressCount)) {
clearInterval(next);
}
}, 250);
}
解决方案
推荐阅读
- python-3.x - 优化邓恩指数计算?
- iphone - 有没有办法使用 Python 访问 iPhone 相机分辨率?
- docker - 如何进入 CoreDNS pod kuberrnetes?
- json - 使用 jenkins groovy 合并 JSON 文件
- c# - 如何在文本框上显示接收到的 UDP 数据?
- import - Odoo 13 Enterprise的哪些应用程序可以支持与品牌生物识别机器连接:NIDEKA?
- neo4j - 如何根据ID获取特定节点的所有父节点
- azure-devops - Azure DevOps 中针对用户故事的障碍
- spring - spring jpa 查询 SQLGrammarException on join @ManyToMany
- django - 从基础模型继承模型的 FK 关联查询优化