【问题标题】:iframe google map is not workingiframe 谷歌地图不工作
【发布时间】:2015-06-25 03:50:52
【问题描述】:

我正在使用iFrame 来显示google-map,但它不起作用。
如果我将 URL 粘贴到浏览器中,则会显示确切的位置。
我不知道为什么它不起作用。

我的 HTML 代码:

<div><iframe src="<?php echo $uni['GoogleMapLink'];?>"  width="97%" height="50%" frameborder="0" style="border:1px solid #ccc;"></iframe></div> 

<?php echo $uni['GoogleMapLink'];?> is https://www.google.co.in/maps/place/Birmingham+City+University/@52.517047,-1.897309,17z/data=!3m1!4b1!4m2!3m1!1s0x4870b

浏览器中的输出是:

<div><iframe src="https://www.google.co.in/maps/place/Birmingham+City+University/@52.517047,-1.897309,17z/data=!3m1!4b1!4m2!3m1!1s0x4870bcf7bed14f49:0x783aa84ea9692f19"  width="97%" height="50%" frameborder="0" style="border:1px solid #ccc;"></iframe></div> 

【问题讨论】:

  • 可能与这个&lt;?php echo $uni['GoogleMapLink'];?&gt;有关
  • 看到我的问题是显示 的输出

标签: php html codeigniter google-maps iframe


【解决方案1】:

您不能在 iframe 中显示该 URL。如果我创建一个包含您的代码的fiddle

<div><iframe src="https://www.google.co.in/maps/place/Birmingham+City+University/@52.517047,-1.897309,17z/data=!3m1!4b1!4m2!3m1!1s0x4870b"  width="97%" height="50%" frameborder="0" style="border:1px solid #ccc;"></iframe></div> 

然后查看 javascript 控制台,我看到了:

Refused to display 'https://www.google.co.in/maps/place/Birmingham+City+University/@52.517047,-1.897309,17z/data=!3m1!4b1!4m2!3m1!1s0x4870b' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.

您应该查看Embed API 或使用 Google 的工具创建可以放在页面上的地图。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-27
    • 1970-01-01
    相关资源
    最近更新 更多