Premise
I'm using the Google Elevation Service to get elevations of all nodes along a path, drawn onto a Leaflet map by a user. This allows me to generate an elevation chart. At the moment, if I make more than 2 requests (there is a limit of 512 locations per request), I always hit an OVER_QUERY_LIMIT
.
Usage Policy
- 2,500 free requests per day, calculated as the sum of client-side and server-side queries; enable billing to access higher daily quotas, billed at $0.50 USD / 1000 additional requests, up to 100,000 requests daily.
- 512 locations per request.
- 50 requests per second*, calculated as the sum of client-side and server-side queries combined.
From the Google Elevation Service Site
I know I'm not hitting the 2500 requests a day (can see in the developer console how many have been made). I also know that there are definitely 512 locations per request, which leaves the only quota to be hitting being the 50 requests per second.
Method
To deal with large volumes of nodes I am doing the following:
- Input list of nodes to function
- Take first chunk (512 locations) from list
- Make API call with that chunk
- Append returned elevations to an array
- Wait for 1 second
- Loop from 2 to 5 until list is depleted
Code in action: Codepen
If I make the waiting time massive in between each request (say 5 seconds), the requests are sent fine, but from what I can tell, I should be able to send 50 requests a second - so a list of 10,000 nodes should take 20 requests, and theoretically not even need a wait - but even with the wait its hitting the error.