37

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?

kamikaze_pilot
  • 14,304
  • 35
  • 111
  • 171

4 Answers4

48

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.

Nick Canzoneri
  • 3,774
  • 1
  • 23
  • 17
  • hey there, thanks for the info...I have another question: what if you want directions to more than 2 places....so for instance newyork to baltimore and then to philadelphia or any other arbitrary number of directions – kamikaze_pilot Jul 09 '10 at 23:24
  • 7
    So, daddr is always stop number 2. To add more waypoints you just add "+to:whatever". So your example would be http://maps.google.com/maps?saddr=new+york&daddr=baltimore+to:philadelphia+to:cleveland – Nick Canzoneri Jul 10 '10 at 01:50
29

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
GreatBlakes
  • 3,971
  • 4
  • 20
  • 28
4

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

Dagg Nabbit
  • 75,346
  • 19
  • 113
  • 141
0

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