【问题标题】:How to embed google map with short url如何使用短网址嵌入谷歌地图
【发布时间】:2013-04-11 21:59:13
【问题描述】:

我有一个不同地方的简短谷歌网址表,例如,

ID|URL
------
1|http://goo.gl/maps/7nps
2|http://goo.gl/maps/wZlPp

取决于 URL 中的参数我需要在浏览器中显示该位置的嵌入地图。

所以,为了嵌入第二张地图,我使用了谷歌给我的 iframe html 脚本:

<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/?ie=UTF8&amp;t=h&amp;ll=40.408791,-3.692586&amp;spn=0.002859,0.00456&amp;z=17&amp;output=embed"></iframe><br /><small><a href="http://maps.google.com/?ie=UTF8&amp;t=h&amp;ll=40.408791,-3.692586&amp;spn=0.002859,0.00456&amp;z=17&amp;source=embed" style="color:#0000FF;text-align:left">View Larger Map</a></small>

它有效,但它使用长网址:http://maps.google.com/?ie=UTF8&t=h&ll=40.408791,-3.692586&spn=0.002859,0.00456&z=17&output=embed

当我尝试用较短的链接替换它时,它不起作用:

<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://goo.gl/maps/wZlPp"></iframe><br />

那里怎么可能使用短链接?

【问题讨论】:

  • 无法将这些链接与 iframe 一起使用,因为 x-frame-options-header 设置为 SAMEORIGIN,这会阻止将文档加载到外部 iframe 中
  • 我说你可以在你的服务器或客户端中查找目标url然后使用它

标签: html google-maps iframe google-maps-api-3


【解决方案1】:

当您查看开发者控制台时,您会看到如下内容:

Load denied by X-Frame-Options: https://maps.google.com/?ie=UTF8&ll=48.858151,2.293611&spn=0.00648,0.021973&t=h&z=16 does not permit cross-origin framing.

所以问题是same origin policy。在这种情况下不能使用短链接。

【讨论】:

    猜你喜欢
    • 2013-06-29
    • 1970-01-01
    • 2016-11-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多