Reputation: 6939
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.
Upvotes: 0
Views: 365
Reputation: 161334
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.
Upvotes: 2