0
votes

I was wondering if someone had the same issue I have sometimes:

I am querying Google's servers and geocoding some places with a setTimeout() loop which resembles the following:

//...

var loop = function() {                
            setTimeout(function() {
                // Here I do the geocode request and create a CustomOverlay which I then show on the map.
                setTimeout(loop, 0); // Let the browser do some other work, e.g. rendering
            }, 125);
};
loop();

//...

Now, I have set the timeout to 125 milliseconds, which means that within 1 second at most 8 requests (8 * 125 = 1000) are made. But sometimes I get the Google's OVER_QUERY_LIMIT status code after a while when the script executes.

Now the documentation (https://developers.google.com/maps/documentation/geocoding/usage-limits) says:

Users of the standard API:

  • 2,500 free requests per day
  • 10 requests per second

Why is OVER_QUERY_LIMIT returned in my case? Is it because I also create a custom Overlay? I use the method overlayProjection.fromLatLngToDivPixel() for each result to convert the lat and lng returned from the Geocoder to pixels and to draw the overlay on the map. Maybe because of it?

Thanks for the attention.

1
Should consider storing the geocoded data...then you only need to geocode it once - charlietfl
You have a standard or premium account? - Erik Philips
You are not allowed to permanently store geocoder results, only "cache" it for a period of time per the terms of use. - geocodezip
Guys, why the down vote? What's wrong with my question? - tonix
@ErikPhilips Standard account. - tonix

1 Answers

2
votes

2500 requests per day works out to 34.56 sec/request over the long term. The 10 request per second rate limit is only valid for short periods of time (approximately 10 requests).

(24 hrs/day * 60 min/hr * 60 sec/min)/2500 requests = 34.56 sec/request

The 2500 requests per day is the hard limit. The 10 requests per second can change depending on server load and other things, including your recent history of requests.