javascript - Google map - 未通过 <iframe> 加载

标签 javascript ruby-on-rails iframe

在 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 包含在内,而不是 Google map 的实际嵌入版本。您的 src 值应类似于 https://www.google.com/maps/embed/v1/place?q=Harrods,Brompton%20Rd,%20UKHere's指向 Google map 嵌入 API 的链接。

关于javascript - Google map - 未通过 &lt;iframe&gt; 加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33732022/

相关文章:

ruby-on-rails - 如何使用 Capybara 确认 javascript 弹出窗口?

mysql - 选择最后一组数据

ruby-on-rails - 是否可以在 Rails 5 的索引页面上创建表单?

javascript - 将 iframe 中使用 Audio 对象创建的音频静音

javascript - angular-ui-layout - 调整大小无法在 iframe 中正常工作

javascript - 使用 javascript 或 jquery 水平滚动 div onclick

jquery - 设置 JavaScript 对象字面量值

javascript - Angular 2 html 指令和属性指令

javascript - 在 iframe javascript 中计算点击次数

javascript - 如何使用jquery在html中选择带有嵌套表的特定元素