从 Google API 中查找多组路线

Find multiple set of routes from Google API

我有下面的 API 端点来查找两个位置之间的路线,

https://maps.googleapis.com/maps/api/directions/json?origin=Brooklyn&destination=Queens&mode=driving

这很完美,但我有不止一组出发地和目的地,例如

 origin1 to destination1
 origin2 to destination2
 origin2 to destination2
 originn to destinationn

而且我需要同时获取路由,但是Google阻止了多次请求后同一IP的连续请求。 我的问题是,是否有任何逻辑或方法可用于在 Google?

的单个请求中查找路由集

Google 路线 API Web 服务不支持多个起点和终点。您只能向一个来源和一个目的地发送请求,实际上您应该遵守文档中规定的每秒允许查询 (QPS) 限制:

https://developers.google.com/maps/documentation/directions/usage-limits

GitHub 上有几个库可以实现节流逻辑以保持在允许的限制内。您可以找到 Java、Python、Go 和 NodeJs 的库:

https://github.com/googlemaps/google-maps-services-python

https://github.com/googlemaps/google-maps-services-java

https://github.com/googlemaps/google-maps-services-go

https://github.com/googlemaps/google-maps-services-js

此外,我注意到 Google 拒绝了为 Web 服务请求批处理功能的尝试。您可以查看此功能请求作为参考:

https://issuetracker.google.com/issues/35818254