最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - OVER_QUERY_LIMIT google maps api v3 - Stack Overflow

programmeradmin1浏览0评论

My application gets addresses from a file that is updated every couple of hours and geocodes them and puts them on google maps.

I'm getting a OVER_QUERY_LIMIT status even though I have not used it since the day before and I'm putting time between each query. I'm putting 2 seconds between each query, this code is used when the function it is in is called which is called after 2 seconds after it's been called before.

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","=" + 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();

My application gets addresses from a file that is updated every couple of hours and geocodes them and puts them on google maps.

I'm getting a OVER_QUERY_LIMIT status even though I have not used it since the day before and I'm putting time between each query. I'm putting 2 seconds between each query, this code is used when the function it is in is called which is called after 2 seconds after it's been called before.

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./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();
Share Improve this question asked Mar 4, 2014 at 13:47 user1721803user1721803 1,1952 gold badges14 silver badges21 bronze badges 4
  • You say the addresses are in a file that are updated every couple of hours - if you don't check which addresses are updated and you (re-)geocode all of them, this could push you over your limit. – ChrisW Commented Mar 4, 2014 at 14:24
  • I dont geocode all of them. I get the address i need from the file based on a search criteria. – user1721803 Commented Mar 4, 2014 at 14:26
  • Do you track how many you're geocoding? – ChrisW Commented Mar 4, 2014 at 14:44
  • No but i'm the only one using it and no way in hell am i reaching 2500 queries. – user1721803 Commented Mar 4, 2014 at 14:54
Add a ment  | 

1 Answer 1

Reset to default 3

Reading documentation about google maps., you can see that

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.

Based on what you told most probably you already used your daily limit.

Based on their licensing policy you can get 2500 request for geocoding.

发布评论

评论列表(0)

  1. 暂无评论