OVER_QUERY_LIMIT in Google Maps API v3: How do I pause/delay in Javascript to slow it down?
Nothing like these two lines appears in Mike Williams' tutorial:
wait = true;
setTimeout("wait = true", 2000);
Here's a Version 3 port:
http://acleach.me.uk/gmaps/v3/plotaddresses.htm
The relevant bit of code is
// ====== Geocoding ======
function getAddress(search, next) {
geo.geocode({address:search}, function (results,status)
{
// If that was successful
if (status == google.maps.GeocoderStatus.OK) {
// Lets assume that the first marker is the one we want
var p = results[0].geometry.location;
var lat=p.lat();
var lng=p.lng();
// Output the data
var msg = 'address="' + search + '" lat=' +lat+ ' lng=' +lng+ '(delay='+delay+'ms)<br>';
document.getElementById("messages").innerHTML += msg;
// Create a marker
createMarker(search,lat,lng);
}
// ====== Decode the error status ======
else {
// === if we were sending the requests to fast, try this one again and increase the delay
if (status == google.maps.GeocoderStatus.OVER_QUERY_LIMIT) {
nextAddress--;
delay++;
} else {
var reason="Code "+status;
var msg = 'address="' + search + '" error=' +reason+ '(delay='+delay+'ms)<br>';
document.getElementById("messages").innerHTML += msg;
}
}
next();
}
);
}
Google Maps API OVER_QUERY_LIMIT
It seems like you may be going over the "# or requests per second" limit. As mentioned in the documentation:
You can exceed the Google Maps API Web Services usage limits by:
- Sending too many requests per day.
- requests too fast, i.e. too many requests per second.
- requests too fast for too long or otherwise abusing the web service.
- Exceeding other usage limits, e.g. points per request in the Elevation API.
To verify that you are hitting that limit:
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.
Related Topics
In JavaScript, Why Is "0" Equal to False, But When Tested by 'If' It Is Not False by Itself
How to Resize Images Proportionally/Keeping the Aspect Ratio
Add Directives from Directive in Angularjs
How to Get the File Name from a Full Path Using JavaScript
How to Focus on a <Div> Using JavaScript Focus() Function
How to Find Prime Numbers Between 0 - 100
How to Filter Multiple Values (Or Operation) in Angularjs
How to Use Jquery for Xml Parsing with Namespaces
Adding Click Event Listener to Elements with the Same Class
Over_Query_Limit in Google Maps API V3: How to Pause/Delay in JavaScript to Slow It Down
What Is Minimum Millisecond Value of Settimeout
Es6 Destructuring Function Parameter - Naming Root Object
Why Does Firebase Lose Reference Outside the Once() Function
Differencebetween Screenx/Y, Clientx/Y and Pagex/Y
When to Use Es6 Class Based React Components VS. Functional Es6 React Components
Find Out Whether Chrome Console Is Open
Window.Location.Href and Window.Open () Methods in JavaScript