尽管 API 已激活,但在尝试使用嵌入地图 API 时出现 ApiNotActivatedMapError

Mat*_*c24 3 html javascript google-maps google-api

我在网页中嵌入了一张地图,但由于某种原因我不断收到 ApiNotActivatedMapError,我正在查看它并且它已被激活。我只是在这里不知所措。

<div id="map" style="width:100%;height:400px">My map will go here</div>

<script>
// Initialize and add the map
function initMap() {
    var mapProp= {
        center:new google.maps.LatLng(51.508742,-0.120850),
        zoom:5,
    };
    var map=new google.maps.Map(document.getElementById("map"),mapProp);
}
</script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=MY_API_KEY&callback=initMap">
</script>
Run Code Online (Sandbox Code Playgroud)

有没有人有这个问题的经验?我错过了一些简单的东西吗?谢谢

Mik*_*ike 8

转到 console.cloud.google.com 并按照以下步骤操作:

1) API 和服务

2) 仪表盘

3) + 启用 APIS 和服务

4) 地图 JavaScript API

5)点击启用按钮