google-mapsgoogle-directions-apigoogle-routes-api

How to return "waypoint_order" in Google Routes API?


I'm developing a system to trace a route using the Google Routes API.

https://developers.google.com/maps/documentation/routes/intermed_waypoints

I have the origin and destination points and between these points there are some points of interest. When tracing the route Google returns me the best route and marks these points on the map.

I'm trying to send the following body inside postman:

{
  "origin":{
      "location":{
        "latLng":{
          "latitude": -15.636545,
          "longitude": -47.633539
        }
      }
    },
  "destination":{
      "location":{
        "latLng":{
          "latitude": -15.630800,
          "longitude": -47.652165
        }
      }
    },
  "intermediates": [
    
    {
      "location":{
        "latLng":{
          "latitude": -15.636709,
          "longitude": -47.659976
        }
      }
    },
    {
      "location":{
        "latLng":{
          "latitude": -15.642289,
          "longitude": -47.658088
        }
      }
    }
  ],
  "travelMode": "DRIVE"
}

I wanted to receive the return of waypoints as an api parameter. What could I send differently within the postman request body to receive the stop order as an array? Similar to what happens today in api directions.

{
  "origin":{
      "location":{
        "latLng":{
          "latitude": -15.636545,
          "longitude": -47.633539
        }
      }
    },
  "destination":{
      "location":{
        "latLng":{
          "latitude": -15.630800,
          "longitude": -47.652165
        }
      }
    },
  "intermediates": [
    
    {
      "location":{
        "latLng":{
          "latitude": -15.636709,
          "longitude": -47.659976
        }
      }
    },
    {
      "location":{
        "latLng":{
          "latitude": -15.642289,
          "longitude": -47.658088
        }
      }
    }
  ],
  "travelMode": "DRIVE"
}

enter image description here


Solution

  • It is now possible to Optimize the order of stops on your route in the Routes API.

    More features have been recently added to the Routes API, making it a lot easier now to Migrate from Directions API or Distance Matrix API.