Make a href which open a Google map with specific address

URL87 picture URL87 · Dec 11, 2014 · Viewed 70.5k times · Source

Suppose I have a variable address - myAddress

I want to create a - <a href="..."></a>

which will open a Google Map with this address .

How to achieve that ?

Answer

Yakov picture Yakov · Dec 11, 2014

You can do it like this:

this is your href: http://maps.google.com/?q= everything that goes after q will be filled in the search filled and submitted, for example: 1200 Pennsylvania Ave SE, Washington, District of Columbia, 20003

So the link looks like this: <a href="http://maps.google.com/?q=1200 Pennsylvania Ave SE, Washington, District of Columbia, 20003">...</a>

If you need the "q" to be dynamic you can do it with simple jQuery code to update your href.