繁体   English   中英

Google Maps JavaScript API 请求被拒绝

[英]Google Maps JavaScript API request denied

我总是收到请求被拒绝的错误。 我使用的 API 密钥在谷歌云控制台中是绿色的。 我已经激活了 Places API、Geocoding API 和 Maps javascript API。 这是我的代码<script src="https://maps.googleapis.com/maps/api/js?key=[MY_KEY]&libraries=places,geometry&callback=initMap" async defer></script>

你有什么想法?

非常感谢

一切正常,将您的 api 密钥替换为 google 在其演示中使用的密钥: https ://jsfiddle.net/api/post/library/pure/ 即使没有密钥,它也对我有用,如下面的 snipet 所示。

我建议您重新访问您的代码,如果没有问题,请尝试删除此密钥并生成另一个。

 let map; function initMap() { map = new google.maps.Map(document.getElementById("map"), { center: { lat: -34.397, lng: 150.644 }, zoom: 8, }); }
 #map { height: 100%; } /* Optional: Makes the sample page fill the window. */ html, body { height: 100%; margin: 0; padding: 0; }
 <div id="map" style="height: 100%;"></div> <script src="https://maps.googleapis.com/maps/api/js?key=&libraries=places,geometry&callback=initMap" async defer> </script>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM