谷歌地图-不通过<iframe>

Google maps - Not loading via <iframe>

本文关键字:lt iframe gt 谷歌地图      更新时间:2023-09-26

在rails 4.2.4中,我试图通过iframe添加谷歌地图功能,但我遇到了类似的错误

Refused to display 'https://maps.googleapis.com/maps/api/js?key=AIsfsdfsdjLr31nsdsdfsdf16LORmV4d89hhg&output=embed' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.

查看文件是,

<iframe width="600" height="450" frameborder="0" style="border:0"
    src="https://maps.googleapis.com/maps/api/js?key=AIsfsdfsdjLr31nsdsdfsdf16LORmV4d89hhg&output=embed" allowfullscreen>
</iframe>

如何解决这个iframe问题?

您将JavaScript文件包含为iframe,而不是谷歌地图的实际嵌入版本。您的src值应该类似于https://www.google.com/maps/embed/v1/place?q=Harrods,Brompton%20Rd,%20UK。这是谷歌地图嵌入API的链接。