Google 地图 API 距离矩阵 - 请求(客户端)另外 100 个元素的延迟时间

Google Maps API Distance Matrix - Delay time to request (client-side) another 100 elements

我有一个迷你地图项目,它使用距离矩阵 Google 地图 API 创建一条从起点到终点的折线(路线)。我的地图中有很多标记,我必须使用距离矩阵 API 连接它们以获取持续时间值。

问题是距离矩阵 API 的总请求超过 100 个元素,正好是 400 个元素。我知道 Google Maps API 每个客户端请求仅限制为 100 个元素。根据文档,

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:

Maximum of 25 origins or 25 destinations per request. Maximum 100 elements per server-side request. Maximum 100 elements per client-side request. 1000 elements per second (EPS), calculated as the sum of client-side and server-side queries.

所以,我决定将 400 个元素分成 4 个请求(每个请求 100 个元素)。 但是,文档没有说明我应该等待多长时间才能请求另外 100 个元素。

有人知道吗?

谢谢。

Google 的 documentation 确实说明了您应该在这里等待多长时间:

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. Once you use this quota, the API enforces rate limits on additional requests on a per-second basis. If too many requests are made within a certain time period, the API returns an OVER_QUERY_LIMIT response code.

因此,您至少需要等待 1 秒,然后才能向距离矩阵客户端服务发出另一个请求。

希望对您有所帮助!