I am always getting an request denied error. The API key I used is green in google cloud console. I have activated the Places API, the Geocoding API and the 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>
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.
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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.