当我在 AMP 页面中添加地图 iframe 时显示错误

Showing error When I add map iframe in AMP page

amp 页面显示错误

但是我添加了
标签直到 600px 高度比它工作正常。

error.js:195 <amp-iframe> elements must be positioned outside the first 75% of the viewport or 600px from the top (whichever is smaller):  <amp-iframe width=​"600" height=​"400" title=​"Google map pin on Googleplex, Mountain View CA" layout=​"responsive" sandbox=​"allow-scripts allow-same-origin allow-popups" frameborder=​"0" src=​"https:​/​/​www.google.com/​maps/​embed/​v1/​place?q=place_id:​ChIJ2eUgeAK6j4ARbn5u_wAGqWA&key=AIzaSyC544Fo4Prg6ZUNNfmi8cC5Rhs4ZckTGSw" class=​"i-amphtml-element i-amphtml-layout-responsive i-amphtml-layout-size-defined i-amphtml-error i-amphtml-layout" i-amphtml-layout=​"responsive">​…​</amp-iframe>​ Current position 195 . Min: 480 Positioning rules don't apply for iframes that use `placeholder`.See https://github.com/ampproject/amphtml/blob/master/extensions/amp-iframe/amp-iframe.md#iframe-with-placeholder for details.

根据 AMP 文档, amp-iframe 有几个重要的细节,旨在使其更安全并避免由单个 iframe 支配的 AMP 文件:

  • amp-iframe 可能不会出现在靠近文档顶部的位置(使用占位符的 iframe 除外,如下所述)。当滚动到顶部时,iframe 必须距离顶部 600 像素或不在视口的前 75% 范围内,以较小者为准。
  • 默认情况下,amp-iframe 是沙盒化的(查看详细信息)。 amp-iframe 只能通过 HTTPS、数据 URI 或 srcdoc 属性请求资源。
  • amp-iframe 不得与容器同源,除非它们不允许沙盒属性中的 allow-same-origin。有关允许的 iframe 来源的更多详细信息,请参阅 "Iframe origin policy" 文档。 可以找到更多详细信息 https://amp.dev/documentation/components/amp-iframe/