【问题标题】:OVER_QUERY_LIMIT Google Geocoding API v3 AJAXOVER_QUERY_LIMIT Google 地理编码 API v3 AJAX
【发布时间】:2014-05-01 17:51:21
【问题描述】:

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

现在,即使应用程序已数天未使用,也会返回 Over_query_limit。

有时它会成功进行地理编码,有时它会返回 over_query_limit,即使未达到限制。

如果在该地理编码上达到 over_query_limit,我会延迟 3 秒的查询。然后它重新运行具有相同地址的代码以再次对其进行地理编码。

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();

【问题讨论】:

标签: javascript ajax google-maps-api-3 google-geocoding-api


【解决方案1】:

实际上,如果您不使用付费地理编码,谷歌有其使用地理编码的限制,因此我建议在创建位置时使用地理编码获取纬度经度,并将其保存到具有相关地址的数据库中,并根据您的要求使用经度经度。或者您可以使用服务器端地理编码,因此与客户端相比,您将获得更多限制,check this

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-20
    • 2013-04-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多