共享谷歌地图:图书馆搜索未知

ber*_*oft 6 google-maps

我正在尝试通过 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)

  • 我只是复制并粘贴上面的代码
  • 我从 Google 地图获取代码,-> 共享 -> 嵌入地图
  • 我没有使用 API

你知道为什么吗?

小智 -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 的说明非常简单。这是您需要的两个链接:

旁注:请注意,在创建密钥时必须提供计费方法,以便 Google 在超过对其 API 的给定请求数量时可以对嵌入地图的使用收取费用。

  • 您好,对于 Google 地图在其自己的平台中创建的嵌入而言,情况并非如此。然而,对于 Embed API 来说确实如此。 (5认同)