Google Maps地理编码API速率限制不正确 [英] Google Maps Geocoding API Incorrect Rate Limiting
问题描述
根据 Google的文档,我每秒限制10个请求。所以,我已经设置我的JavaScript来搅动地址数组,并在每个批次之间延迟。
所以我的功能是设置两个confif变量我可以设置:addressesPerBatch和timeoutPerBatch - 很明显,每个人应该做什么。你会认为,从Google的文档来看,我将被允许
addressesPerBatch = 10;
timeoutPerBatch = 1000; //这是毫秒
我绝对不是。当我快速发送请求时,我很快就达到了我的速率限制。我找到的最好的地方实际是在
addressesPerBatch = 2;
timeoutPerBatch = 2000;
所以,这是我的JavaScript的问题,还是Google限价的问题?
我创建了一个jsfiddle,所以你可以更好地了解我在做什么:
http://jsfiddle.net/Qt4gV/1/
根据Google代码页上类似问题的答案:Geocoding API请求率限制不被披露以帮助最大程度地减少服务滥用。
https://code.google.com/p/gmaps-api-issues/issues/detail?id= 3099#c4
像评论中提到的@jwegner一样,应该检查返回的状态代码,并为OVER_QUERY_LIM IT。
I'm adding a mapping function to one of the internal tools used by my company. Long story short, we have a list of about 50 addresses that need to be placed on a map. I'm using Google Maps so that it is an interactive map, and then the javascript API for geocoding and adding the markers.
According to Google's documentation, I am limitted to 10 requests per second. So, I've set my javascript to churn through an array of addresses, and put a delay in between each batch.
So my function is setup with two confif variables that I can set: addressesPerBatch and timeoutPerBatch - pretty obvious what each one should do. You would think that, judging from Google's documentation, I would be allowed
addressesPerBatch = 10;
timeoutPerBatch = 1000; //That's in milliseconds
I am most certainly not. I very quickly hit my rate limit when I send requests that quickly. The sweet spot that I've found is actually around"
addressesPerBatch = 2;
timeoutPerBatch = 2000;
So, is this a problem with my javascript, or a problem with Google's rate limiting?
I've created a jsfiddle so you can get a better idea of exactly what I'm doing: http://jsfiddle.net/Qt4gV/1/
According to the answer to a similar question on the Google code page: "The Geocoding API request rate limit is not to be disclosed to help minimize service abuse." https://code.google.com/p/gmaps-api-issues/issues/detail?id=3099#c4
Like what @jwegner mentioned in the comments, one should check the returned status code and implement constant backoff for the case "OVER_QUERY_LIMIT".
这篇关于Google Maps地理编码API速率限制不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!