0

Im very bad at pasting the code here so here is a complete running example: https://plnkr.co/edit/klOViMslWjBFy3KTq507?p=preview

<html>
  <body>
<script>
  function initMap() {
    geocoder = new google.maps.Geocoder();
    console.log('sending requests');
    geocodeAddress(geocoder,0);
  }
  function geocodeAddress(geocoder,cnt) {
    if(cnt==50){
      console.log('ending sending 50 requests');
      return ; 
    }
var address = 'USA';
console.log('sending request');
geocoder.geocode({'address': address}, function(results, status) {

if (status === google.maps.GeocoderStatus.OK) {
console.log('got response OK');  
} else {
  console.error('got response wrong',status);
}
});

setTimeout(function(){
geocodeAddress(geocoder,cnt+1); 
},100);
}
</script>

<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?china=false&v=3.20&libraries=weather,geometry,visualization&language=en&sensor=false&callback=initMap"></script>
</body>


</html>

Im sending request every 100ms, which means i send 10 requests/second which is the exact client limit. Yet still im getting OVER_LIMIT error.... Why?

duncan
  • 31,401
  • 13
  • 78
  • 99
repo
  • 748
  • 1
  • 8
  • 19
  • Seems like you have exceeded your usage limit. – Kruga Feb 10 '16 at 09:42
  • [usage limits](https://developers.google.com/maps/documentation/javascript/usage) – Craicerjack Feb 10 '16 at 10:14
  • Try waiting a few seconds and do a single request. If it still says it's over the limit, you probably hit the daily cap. Else, try doing fewer than 10 requests per second, until you don't get the error. I can't find a source on the 10/sec limit, it might be different. – Kruga Feb 10 '16 at 10:29
  • I'm voting to close this question as off-topic because we cannot tell you why some 3rd party has decided you're over some arbitrarily decided limit. Contact said 3rd party, perhaps? – deceze Feb 10 '16 at 10:32

1 Answers1

0

The google maps have quotas and rate limits. Google seems to be a lot more restrictive with the limits than they put in the documentation, most likely depends on server loading. I had made a similar application and I had differents limits depend by the hour and the date (meaning that they throw more OVER_LIMIT when more people want to access the geocode).

My experience says that only if you do this

setTimeout(function(){
  geocodeAddress(geocoder,cnt+1); 
},1000);

you will not get OVER_LIMIT.

You will find more solutions here: OVER_QUERY_LIMIT in Google Maps API v3: How do I pause/delay in Javascript to slow it down?

Community
  • 1
  • 1
Thomas Karachristos
  • 3,237
  • 18
  • 22