我正在尝试通过 IFRAME 共享 Google 地图,但控制台中出现此错误
图书馆检索未知。请参阅https://developers.google.com/maps/documentation/javascript/libraries
<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d2795.5423816131142!2d11.312607315808078!3d45.519289937786425!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x477f48c46ad35441%3A0x9a16514436b0fe8e!2sMarmi%20Zem%20di%20Ziche%20Enrico!5e0!3m2!1sit!2sit!4v1676708610573!5m2!1sit!2sit" width="600" height="450" style="border:0;" allowfullscreen="" loading="lazy" referrerpolicy="no-referrer-when-downgrade"></iframe>
Run Code Online (Sandbox Code Playgroud)
<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d2795.5423816131142!2d11.312607315808078!3d45.519289937786425!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x477f48c46ad35441%3A0x9a16514436b0fe8e!2sMarmi%20Zem%20di%20Ziche%20Enrico!5e0!3m2!1sit!2sit!4v1676708610573!5m2!1sit!2sit" width="600" height="450" style="border:0;" allowfullscreen="" loading="lazy" referrerpolicy="no-referrer-when-downgrade"></iframe>
Run Code Online (Sandbox Code Playgroud)
你知道为什么吗?
小智 -3
您收到上述控制台错误是因为您必须使用 [Google Maps Platform API key ]嵌入 iframe 。
例子:
<script async defer src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap" type="text/javascript"></script>
Run Code Online (Sandbox Code Playgroud)
代替:
<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d2795.5423816131142!2d11.312607315808078!3d45.519289937786425!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x477f48c46ad35441%3A0x9a16514436b0fe8e!2sMarmi%20Zem%20di%20Ziche%20Enrico!5e0!3m2!1sit!2sit!4v1676708610573!5m2!1sit!2sit" width="600" height="450" style="border:0;" allowfullscreen="" loading="lazy" referrerpolicy="no-referrer-when-downgrade"></iframe>
Run Code Online (Sandbox Code Playgroud)
Google Maps Platform 文档对于部署此 iframe 的说明非常简单。这是您需要的两个链接:
如何嵌入地图:https://developers.google.com/maps/documentation/embed/embedding-map ?hl=es-419
API 使用:https ://developers.google.com/maps/documentation/embed/get-api-key
旁注:请注意,在创建密钥时必须提供计费方法,以便 Google 在超过对其 API 的给定请求数量时可以对嵌入地图的使用收取费用。
归档时间: |
|
查看次数: |
1835 次 |
最近记录: |