【问题标题】:Route optimization using Google Direction API for Mobile App使用 Google Direction API for Mobile App 进行路线优化
【发布时间】:2019-08-21 14:05:49
【问题描述】:

我的应用中有一个纬度和经度列表,使用 Google 方向 API 或使用任何其他 Google API 是否可以根据时间的最佳路线安排纬度和经度。

在谷歌搜索时,我确实找到了这个 API https://developers.google.com/maps/documentation/directions/start#sample-request

但在这个 API 中,谷歌要求提供原产地和目的地,而不是地理编码列表。有什么方法可以使用地理编码列表来实现这一点。

【问题讨论】:

    标签: android google-maps google-directory-api


    【解决方案1】:

    使用更具体的文档:https://developers.google.com/maps/documentation/directions/intro#optional-parameters。您需要带有地名的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
    

    或纬度/经度:

    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
    

    encoded polyline:

    https://maps.googleapis.com/maps/api/directions/json?
    origin=sydney,au&destination=perth,au
    &waypoints=via:enc:lexeF{~wsZejrPjtye@:
    &key=YOUR_API_KEY
    

    还有:

    或者,您可以将 optimize:true 作为第一个参数传递 允许路线服务优化的航路点参数 通过以更有效的方式重新安排航点来提供提供的路线 命令。 (这个优化是traveling salesperson problem的一个应用。)

    您还可以使用 Java Client for Google Maps Services 作为 Directions API 请求的包装器。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多