Html 制作一个打开带有特定地址的谷歌地图的href

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27419509/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 03:10:41  来源:igfitidea点击:

Make a href which open a Google map with specific address

htmlgoogle-mapshref

提问by URL87

Suppose I have a variable address - myAddress

假设我有一个可变地址 - myAddress

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

我想创建一个 - <a href="..."></a>

which will open a Google Map with this address .

这将打开一个带有这个地址的谷歌地图。

How to achieve that ?

如何做到这一点?

回答by Yakov

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

这是您的 href:http: //maps.google.com/?q= q 之后的所有内容都将在已填写并提交的搜索中填写,例如: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>

所以链接看起来像这样: <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.

如果您需要“q”是动态的,您可以使用简单的 jQuery 代码来更新您的 href。