iframe谷歌地图不起作用



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

我的网页代码:

<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> 

不允许在 iframe 中显示该 URL。 如果我创建一个包含您的代码的小提琴:

<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'.

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

最新更新