使用移动应用程序 Google 方向 API 的路线优化
Route optimization using Google Direction API for Mobile App
我的应用程序中有一个纬度和经度列表,使用 Google 方向 API 或使用任何其他 Google API 是否可以安排纬度和经度基于随时间的最佳路线。
谷歌搜索时我确实找到了这个 API
https://developers.google.com/maps/documentation/directions/start#sample-request
但在此 API google 中要求提供起点和终点而不是地理编码列表。有什么办法可以使用地理编码列表来实现这一点。
使用更具体的文档:https://developers.google.com/maps/documentation/directions/intro#optional-parameters. You need waypoints
带有地名的可选参数:
https://maps.googleapis.com/maps/api/directions/json?
origin=Boston,MA&destination=Concord,MA
&waypoints=Charlestown,MA|via:Lexington,MA
&key=YOUR_API_KEY
或latitude/longitude:
https://maps.googleapis.com/maps/api/directions/json?
origin=sydney,au&destination=perth,au
&waypoints=via:-37.81223%2C144.96254%7Cvia:-34.92788%2C138.60008
&key=YOUR_API_KEY
https://maps.googleapis.com/maps/api/directions/json?
origin=sydney,au&destination=perth,au
&waypoints=via:enc:lexeF{~wsZejrPjtye@:
&key=YOUR_API_KEY
并且:
Optionally, you may pass optimize:true as the first argument within
the waypoints parameter to allow the Directions service to optimize
the provided route by rearranging the waypoints in a more efficient
order. (This optimization is an application of the traveling salesperson problem.)
您还可以使用 Java Client for Google Maps Services 作为路线 API 请求的包装器。
我的应用程序中有一个纬度和经度列表,使用 Google 方向 API 或使用任何其他 Google API 是否可以安排纬度和经度基于随时间的最佳路线。
谷歌搜索时我确实找到了这个 API https://developers.google.com/maps/documentation/directions/start#sample-request
但在此 API google 中要求提供起点和终点而不是地理编码列表。有什么办法可以使用地理编码列表来实现这一点。
使用更具体的文档:https://developers.google.com/maps/documentation/directions/intro#optional-parameters. You need waypoints
带有地名的可选参数:
https://maps.googleapis.com/maps/api/directions/json? origin=Boston,MA&destination=Concord,MA &waypoints=Charlestown,MA|via:Lexington,MA &key=YOUR_API_KEY
或latitude/longitude:
https://maps.googleapis.com/maps/api/directions/json? origin=sydney,au&destination=perth,au &waypoints=via:-37.81223%2C144.96254%7Cvia:-34.92788%2C138.60008 &key=YOUR_API_KEY
https://maps.googleapis.com/maps/api/directions/json? origin=sydney,au&destination=perth,au &waypoints=via:enc:lexeF{~wsZejrPjtye@: &key=YOUR_API_KEY
并且:
Optionally, you may pass optimize:true as the first argument within the waypoints parameter to allow the Directions service to optimize the provided route by rearranging the waypoints in a more efficient order. (This optimization is an application of the traveling salesperson problem.)
您还可以使用 Java Client for Google Maps Services 作为路线 API 请求的包装器。