is there a way to pass arguments to google map's get directions functionality?

Is there a way to use maps.google.com's get direction's functionality so that I can pass in the arguments for the directions from the url?

Answers


You can use the following url parameters.

saddr for start address

daddr for destination address

The url would be http://maps.google.com/maps?saddr=new+york&daddr=baltimore

The values you pass in can be pretty much whatever you can type into the web app, ie names of places/lat longs/etc. Also, make sure you use a + character for spaces.


Here are some standard HTML links for different Google Maps functions. With the new syntax, you can have a link to multiple destination directions (however, it is not possible with query parameters)- see the last example below. I keep an updated post here.

//Spaces can be changed to "+" or encoded as "%20".

//Linking to a location (No directions)
https://www.google.com/maps?q=760+West+Genesee+Street+Syracuse+NY+13204

//No starting point (User input required to generate directions).
https://www.google.com/maps?daddr=760+West+Genesee+Street+Syracuse+NY+13204

//With a set location as starting point (Automatically generates directions with no user input required).
https://www.google.com/maps?saddr=760+West+Genesee+Street+Syracuse+NY+13204&daddr=314+Avery+Avenue+Syracuse+NY+13204

//With "My Location" as starting point (Automatically generates directions with no user input required).
https://www.google.com/maps?saddr=My+Location&daddr=760+West+Genesee+Street+Syracuse+NY+13204

//Current Location to Latitude and Longitude
https://www.google.com/maps?saddr=My+Location&daddr=43.12345,-76.12345

//Query search of a Latitude and Longitude
//Also shows setting a default zoom level
https://www.google.com/maps?ll=43.12345,-76.12345&q=food&z=14

//String search as destination
https://www.google.com/maps?saddr=My+Location&daddr=Pinckney+Hugo+Group

//Multiple destination directions (using new syntax). Check my linked post above for the most up-to-date versions.
https://www.google.com/maps/dir/760+W+Genesee+St+Syracuse+NY+13204/314+Avery+Ave+Syracuse+NY+13204/9090+Destiny+USA+Dr+Syracuse+NY+13204

Sure can.

Directions from ATL to LAX:

http://maps.google.com/maps?saddr=atl&daddr=lax

Updated:

Atlanta to LaGuardia to LA to Andrau Airpark...

http://maps.google.com/maps?source=s_d&saddr=ATL&daddr=LGA+to:LAX+to:AAP


As long as you have one saddr and one daddr, tt seems you can +to: for additional points before or after daddr. In other words, these two are equivalent: https://maps.google.com/maps?source=s_d&saddr=ATL&daddr=LGA+to:LAX+to:AAP and https://maps.google.com/maps?source=s_d&saddr=ATL+to:LGA+to:LAX&daddr=AAP


Need Your Help

Get latitude and longitude based on Address using Geocoder class in iOS

ios iphone objective-c geocoding

I got the current location based on the Longitude and Latitude values and then I also got multiple places on google map using Annotation. Now I want to get the longitude and latitude values based o...

Variadic Template in VS 2012 (Visual C++ November 2012 CTP)

c++ visual-c++ c++11 visual-c++-2012

I installed Visual C++ Compiler November 2012 CTP and created a C++ console project. I wrote this in