gpt4 book ai didi

javascript - OVER_QUERY_LIMIT 谷歌地图 API v3

转载 作者:行者123 更新时间:2023-11-29 19:42:25 25 4
gpt4 key购买 nike

我的应用程序从一个每隔几个小时更新一次的文件中获取地址,并对它们进行地理编码并将它们放在谷歌地图上。

我收到了 OVER_QUERY_LIMIT 状态,即使我从前一天起就没有使用过它,并且我在每个查询之间放置了时间。我在每个查询之间放置 2 秒,当调用它所在的函数时使用此代码,该函数在之前被调用后 2 秒后调用。

var xmlhttp
var status;

if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
}
else{// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}

var lAddress = tAddress.replace(/ /g, " +");


xmlhttp.open("GET","http://maps.googleapis.com/maps/api/geocode/json?address=" + lAddress +"&sensor=false", false);

xmlhttp.onreadystatechange = function(){
if (xmlhttp.readyState == 4 && xmlhttp.status == 200){

var result = JSON.parse(xmlhttp.responseText);

status = result.status;


if(status == google.maps.GeocoderStatus.OK){
precise[index].found = 1;
precise[index].lat = result.results[0].geometry.location.lat;
precise[index].lng = result.results[0].geometry.location.lng;
precise[index].addr = tAddress;

}
else if(status == google.maps.GeocoderStatus.OVER_QUERY_LIMIT){
alert("Search limit reached. Please try again tomorrow.");
}
}
}


xmlhttp.send();

最佳答案

阅读关于 google maps. 的文档,你可以看到

If you exceed the usage limits you will get an OVER_QUERY_LIMIT status code as a response.

This means that the web service will stop providing normal responses and switch to returning only status code OVER_QUERY_LIMIT until more usage is allowed again. This can happen:

  1. Within a few seconds, if the error was received because your application sent too many requests per second.
  2. Some time in the next 24 hours, if the error was received because your application sent too many requests per day. The time of day at which the daily quota for a service is reset varies between customers and for each API, and can change over time.

Upon receiving a response with status code OVER_QUERY_LIMIT, your application should determine which usage limit has been exceeded. This can be done by pausing for 2 seconds and resending the same request. If status code is still OVER_QUERY_LIMIT, your application is sending too many requests per day. Otherwise, your application is sending too many requests per second.

根据您所说很可能您已经用完了每日限额。

基于他们的 licensing policy你可以获得 2500 个地理编码请求。

关于javascript - OVER_QUERY_LIMIT 谷歌地图 API v3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22173701/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com