[英]Google Maps API Distance Matrix - Delay time to request (client-side) another 100 elements
I have a mini-map project that uses Distance Matrix Google Maps API to create a polyline (route) from start point to end point.我有一个迷你地图项目,它使用距离矩阵 Google Maps API 创建从起点到终点的折线(路线)。 I have many markers in my map and I have to connect them using Distance Matrix API to fetch the duration value.
我的地图中有很多标记,我必须使用距离矩阵 API 将它们连接起来以获取持续时间值。
The problem is the total requests of the Distance Matrix API are more than 100 elements, exactly 400 elements.问题是距离矩阵 API 的总请求超过 100 个元素,正好是 400 个元素。 I know that Google Maps API limit only to 100 elements per client-side request.
我知道 Google Maps API 将每个客户端请求限制为 100 个元素。 According to the documentation,
根据文档,
While you are no longer limited to a maximum number of elements per day (EPD), the following usage limits are still in place for the Distance Matrix API:
虽然您不再受到每天最大元素数 (EPD) 的限制,但距离矩阵 API 仍然存在以下使用限制:
Maximum of 25 origins or 25 destinations per request.
每个请求最多 25 个起点或 25 个目的地。 Maximum 100 elements per server-side request.
每个服务器端请求最多 100 个元素。 Maximum 100 elements per client-side request.
每个客户端请求最多 100 个元素。 1000 elements per second (EPS), calculated as the sum of client-side and server-side queries.
每秒 1000 个元素 (EPS),计算为客户端和服务器端查询的总和。
So, I decide to divide the 400 elements into 4 requests (100 elements each).因此,我决定将 400 个元素分成 4 个请求(每个请求 100 个元素)。 However, the documentation doesn't state how long should I wait to request another 100 elements.
但是,文档没有说明我应该等待多长时间来请求另外 100 个元素。
Does anyone know?有人知道吗?
Thank you.谢谢你。
Google's documentation does say how long you should wait here: Google 的文档确实说明了您应该在这里等待多长时间:
Note: The rate limit is applied per user session, regardless of how many users share the same project.
注意:速率限制适用于每个用户会话,无论有多少用户共享同一个项目。 When you first load the API, you are allocated an initial quota of elements.
首次加载 API 时,会为您分配一个初始配额。 Once you use this quota, the API enforces rate limits on additional requests on a per-second basis.
使用此配额后,API 会以每秒为基础对额外请求实施速率限制。 If too many requests are made within a certain time period, the API returns an OVER_QUERY_LIMIT response code.
如果在特定时间段内发出过多请求,API 将返回 OVER_QUERY_LIMIT 响应代码。
So you'll need to wait at least 1 second before you make another request to the Distance Matrix client-side service.因此,您需要等待至少 1 秒钟,然后才能向距离矩阵客户端服务发出另一个请求。
Hope this helps!希望这可以帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.