google-mapsgoogle-distancematrix-api

Unable to set mode for google maps distance matrix


I'm following this guide: https://developers.google.com/maps/documentation/distance-matrix/distance-matrix

And this request works fine for me:

$ curl -L -X GET 'https://maps.googleapis.com/maps/api/distancematrix/json?origins=Seattle&destinations=San+Francisco&mode=DRIVING&key=<API_KEY>'
{
   "destination_addresses" : [ "San Francisco, CA, USA" ],
   "origin_addresses" : [ "Seattle, WA, USA" ],
   "rows" : [
      {
         "elements" : [
            {
               "distance" : {
                  "text" : "1,300 km",
                  "value" : 1299780
               },
               "duration" : {
                  "text" : "12 hours 44 mins",
                  "value" : 45815
               },
               "status" : "OK"
            }
         ]
      }
   ],
   "status" : "OK"
}

but the result when I try adding the param mode=WALKING, it gives the exact same result.

I have tried with multiple locations I always get same the driving distance and duration.

How can I get the walking result? Currently I don't see any differences when updating the mode.


Solution

  • I get a different value for the result if I use the documented parameter &mode=walking

    {
       "destination_addresses" : [ "San Francisco, CA, USA" ],
       "origin_addresses" : [ "Seattle, WA, USA" ],
       "rows" : [
          {
             "elements" : [
                {
                   "distance" : {
                      "text" : "1,383 km",
                      "value" : 1383163
                   },
                   "duration" : {
                      "text" : "11 days 10 hours",
                      "value" : 987899
                   },
                   "status" : "OK"
                }
             ]
          }
       ],
       "status" : "OK"
    }
    

    documentation

    mode
    For the calculation of distances and directions, you may specify the transportation mode to use. By default, DRIVING mode is used. By default, directions are calculated as driving directions. The following travel modes are supported:

    • driving (default) indicates standard driving directions or distance using the road network.
    • walking requests walking directions or distance via pedestrian paths & sidewalks (where available).
    • bicycling requests bicycling directions or distance via bicycle paths & preferred streets (where available).
    • transit requests directions or distance via public transit routes (where available). If you set the mode to transit, you can optionally specify either a departure_time or an arrival_time. If neither time is specified, the departure_time defaults to now (that is, the departure time defaults to the current time). You can also optionally include a transit_mode and/or a transit_routing_preference.