Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

google-maps

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?

like image 936
kamikaze_pilot Avatar asked Jul 09 '10 23:07

kamikaze_pilot


People also ask

How do I use Google direction API?

Go to the Google Maps Platform > Credentials page. On the Credentials page, click Create credentials > API key. The API key created dialog displays your newly created API key. Click Close.


2 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.

like image 137
Nick Canzoneri Avatar answered Sep 28 '22 03:09

Nick Canzoneri


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 
like image 26
GreatBlakes Avatar answered Sep 28 '22 03:09

GreatBlakes