OVER_QUERY_LIMIT while using google maps

孤街浪徒 提交于 2019-11-26 18:52:49
Elijah Saounkine

Probably you are sending too many requests per second and Google doesn't let you do that.

Read http://code.google.com/apis/maps/faq.html#geocoder_classorhttp

Geocoding in the JavaScript API is rate-limited. When you first load the API, you can send 10 requests for address geocoding or 5 for reverse (latlng) geocoding before you get an OVER_QUERY_LIMIT response. When you do, use "exponential backoff" to delay your queries.

You may also want to join the discussion in Issue 4805 (gmaps-api-issues).

If you are using an autocomplete, try using Google's Places Autocomplete API. (Even though this isn't exactly what he asked, I assume many will arrive here from this question)

Yaswanth

Have a list of API's and use them randomly for each request . For Example in python

like keys = [key1,key1,key3....]

location = Geocoder(random.choice(keys)).geocode(address) 

or

location = Geocoder(random.choice(keys)).reverse_geocode(Lat,Long)

Based on your Requirement

First read this article. https://developers.google.com/maps/premium/previous-licenses/articles/usage-limits

If you are send many request in one second then use delay method.

function sleep(milliSeconds) {
  var startTime = new Date().getTime();
  while (new Date().getTime() < startTime + milliSeconds);
}

call this method in your loop structure. sleep(2200);

sachin gavas

We can use ajax queue.

At a time 20 ajax request will get executed and others will wait in the queue.

Create multiple geocode key and keep in an array and use it randomly for each ajax request.

Here I have loaded 2200 markers. It takes around 1 min to add 2200 locations.

<https://jsfiddle.net/suchg/qm1pqunz/11/>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!