簡體   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