【问题标题】:Google Maps API & Michael Jaspers JQuery CodeGoogle Maps API 和 Michael Jaspers JQuery 代码
【发布时间】:2018-10-16 20:03:09
【问题描述】:

多年来,我一直在多个网站上使用 Micheal Jaspers 出色的 JQuery 和 HTML 代码convert address tags into Google Map

这是 Michael 的 HTML 代码

<address>
1600 Pennsylvania Avenue NW Washington, DC 20500
</address>

这是 Michael 的 JQuery 代码

$(document).ready(function () {
    //Convert address tags to google map links - Copyright Michael Jasper 2011
    $('address').each(function () {
        var link = "<a href='http://maps.google.com/maps?q=" + encodeURIComponent( $(this).text() ) + "' target='_blank'>" + $(this).text() + "</a>";
        $(this).html(link);
    });
});

他的代码对用户非常友好,并且易于在动态 PHP 应用程序中实现 - 正如他所说,用户只需输入正确的地址。我担心现在谷歌坚持每个人都有一个 API,并且无密钥 API 地图使用将不再起作用,我的应用程序将不再正确呈现地图。

此代码的结果是,加载的是直接从 Google 地图到 IFrame 中的嵌入地图,从技术上讲,它们仍然是免费的。

我无法支持@xomena 的回答,但他是正确的。我确认,在 7 月 16 日之后,如果您只是想在您的网站上嵌入地图,或者在需要多个地址时在整个网站范围内生成地图,使用此代码没有问题。

【问题讨论】:

    标签: javascript jquery api google-maps


    【解决方案1】:

    请注意,您的示例中使用的链接与 Google Maps API 无关。您可以使用消费者应用程序的 URL 创建链接或 iframe,该应用程序是一个单独的产品,并且没有任何需要 API 密钥的内容。

    API 密钥适用于 Maps JavaScript APIMaps Embed APIMaps Static APIMaps SDK for AndroidMaps SDK for iOS,但在您的示例中,这些 API 均未涉及。

    您无需在代码中包含任何 API 即可打开 Google 地图网站链接。

    另外,我建议更改链接以使用记录和支持的Google Maps URLs。请注意,Google 地图网址也不需要 API 密钥。

    希望我的回答能解决你的疑惑!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-07-27
      • 2015-11-09
      • 2012-10-25
      • 2013-12-18
      • 2012-02-23
      • 1970-01-01
      • 2019-07-14
      相关资源
      最近更新 更多