我们的网站显示警告提示“此页面无法正确加载Google Maps”。 我正在使用symfony2的“ ivory-google-map”捆绑包。 在控制台中,我们发现警告为“ Google Maps JavaScript API警告:NoApiKeys https://developers.google.com/maps/documentation/javascript/error-messages#no-api-keys” 任何帮助将不胜感激。
答案 0 :(得分:4)
如错误消息所述,您需要APIKey才能删除此错误。
您可以从https://developers.google.com/maps/documentation/javascript/get-api-key#get-an-api-key
获取APIKey并将该密钥应用于您的代码,例如:
<script async defer src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap" type="text/javascript"></script>
之后,以上错误将不再存在!
答案 1 :(得分:1)
如果您不想购买API密钥,而只需要一张静态地图,则可以使用iFrame来完成。
<div class="mapouter"><div class="gmap_canvas"><iframe width="600" height="500" id="gmap_canvas" src="https://maps.google.com/maps?q=university%20of%20san%20francisco&t=&z=13&ie=UTF8&iwloc=&output=embed" frameborder="0" scrolling="no" marginheight="0" marginwidth="0"></iframe><a href="https://www.pureblack.de"></a></div><style>.mapouter{text-align:right;height:500px;width:600px;}.gmap_canvas {overflow:hidden;background:none!important;height:200px;width:300px;}</style></div>
但是我不知道这将持续多久