Search code examples
iosjsongoogle-mapsgoogle-maps-sdk-iosdirections

Get Google Maps walking directions JSON instead of driving


I'm using this URL to get JSON directions (and showing in on map using GMSPolyLine):

https://maps.googleapis.com/maps/api/directions/json?&origin=%@&destination=%@&sensor=false

But the result it returns me is for driving and I want the user to choose between walking and driving.

Can anyone give me the URL for walking/choosing from walking or driving?

Thank you very much!


Solution

  • Set a URL-parameter mode to the value walking

    https://maps.googleapis.com/maps/api/directions/json?&origin=%@&destination=%@&mode=walking
    

    https://developers.google.com/maps/documentation/directions/intro#TravelModes