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?
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With