javascript - 尽管 API 已激活,但尝试使用嵌入 map API 时出现 ApiNotActivatedMapError

标签 javascript html google-maps google-api

我正在网页中嵌入 map ,但由于某种原因我不断收到 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>

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

最佳答案

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

1) API 和服务

2) 仪表盘

3) + 启用 APIS 和服务

4) map JavaScript API

5) 点击启用按钮

关于javascript - 尽管 API 已激活,但尝试使用嵌入 map API 时出现 ApiNotActivatedMapError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51273970/

相关文章:

javascript - jquery - 折叠/扩展 div?

javascript - Highcharts 圆环图自定义

javascript - JQuery UI slider 未捕获类型错误 : Cannot read property 'addClass' of undefined

javascript - 当我打开 infoWindow (UTF-8) 时,Google map 变得很奇怪

java - 使用 Android Google Maps API 设置 MapType 空指针异常

javascript - 当我在 $scope 中设置数据时,在 bootstrap 模式上获取数据时遇到 angularJs 中的问题

javascript - html标签作为jquery中的字符串

javascript - CSS动画和Jquery2

javascript - Google Prettify 线条颜色超出可见区域(可预滚动)

python - 请求 google directions api 错误地要求传感器