Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I Geocode 20 addresses without receiving an OVER_QUERY_LIMIT response?

Using the Google Geocoder v3, if I try to geocode 20 addresses, I get an OVER_QUERY_LIMIT unless I time them to be ~1 second apart, but then it takes 20 seconds before my markers are all placed.

Is there any other way to do it, other than storing the coordinates in advance?

like image 510
Michiel van Oosterhout Avatar asked Mar 10 '10 17:03

Michiel van Oosterhout


People also ask

What is the best way to geocode addresses?

1. Google Maps Geocoding. Google Maps has become everyone's favorite source for navigation, traffic, transit, and location information.

What does geocoder failed due to Over_query_limit?

If you are getting the error OVER_QUERY_LIMIT when trying to geocode an address with Google set as geocoding provider, this means that you exceeded the Google Maps Platform web services usage limits by: sending too many requests per day or e.g. by. sending requests too fast, i.e. too many requests per second.

Is Google reverse geocoding API free?

It's free as long as you credit them and you need fewer than 15000 lookups per day. You can pay if you need more.


2 Answers

No, there is not really any other way : if you have many locations and want to display them on a map, the best solution is to :

  • fetch the latitude+longitude, using the geocoder, when a location is created
  • store those in your database, alongside the address
  • and use those stored latitude+longitude when you want to display the map.

This is, of course, considering that you have a lot less creation/modification of locations than you have consultations of locations.


Yes, it means you'll have to do a bit more work when saving the locations -- but it also means :

  • You'll be able to search by geographical coordinates
    • i.e. "I want a list of points that are near where I'm now"
  • Displaying the map will be a lot faster
    • Even with more than 20 locations on it
  • Oh, and, also (last but not least) : this will work ;-)
    • You will less likely hit the limit of X geocoder calls in N seconds.
    • And you will less likely hit the limit of Y geocoder calls per day.
like image 63
Pascal MARTIN Avatar answered Nov 04 '22 11:11

Pascal MARTIN


You actually do not have to wait a full second for each request. I found that if I wait 200 miliseconds between each request I am able to avoid the OVER_QUERY_LIMIT response and the user experience is passable. With this solution you can load 20 items in 4 seconds.

$(items).each(function(i, item){    setTimeout(function(){      geoLocate("my address", function(myLatlng){       ...     });    }, 200 * i);  } 
like image 40
gabeodess Avatar answered Nov 04 '22 11:11

gabeodess