简体   繁体   English

Google Maps JavaScript API 请求被拒绝

[英]Google Maps JavaScript API request denied

I am always getting an request denied error.我总是收到请求被拒绝的错误。 The API key I used is green in google cloud console.我使用的 API 密钥在谷歌云控制台中是绿色的。 I have activated the Places API, the Geocoding API and the Maps javascript API.我已经激活了 Places API、Geocoding API 和 Maps javascript API。 This is my code <script src="https://maps.googleapis.com/maps/api/js?key=[MY_KEY]&libraries=places,geometry&callback=initMap" async defer></script>这是我的代码<script src="https://maps.googleapis.com/maps/api/js?key=[MY_KEY]&libraries=places,geometry&callback=initMap" async defer></script>

Do you have any ideas?你有什么想法?

Thanks a lot非常感谢

Everything works just fine replacing your api key with the one that google uses on its demo: https://jsfiddle.net/api/post/library/pure/ It have worked for me even withou key, as shown in the snipet bellow.一切正常,将您的 api 密钥替换为 google 在其演示中使用的密钥: https ://jsfiddle.net/api/post/library/pure/ 即使没有密钥,它也对我有用,如下面的 snipet 所示。

I suggest you to revisit your code and if nothing is wrong, try deleting this key and generate another one.我建议您重新访问您的代码,如果没有问题,请尝试删除此密钥并生成另一个。

 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