最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Getting ApiNotActivatedMapError when trying to use embed map API despite the API being activated - Stack Overflow

programmeradmin1浏览0评论

I'm embedding a map in a webpage but I keep getting a ApiNotActivatedMapError for some reason, I'm looking at it and it is activated. I'm just at a loss here.

<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=";callback=initMap">
</script>

Does anybody have any experience with this problem? Am I missing something simple? Thanks

I'm embedding a map in a webpage but I keep getting a ApiNotActivatedMapError for some reason, I'm looking at it and it is activated. I'm just at a loss here.

<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./maps/api/js?key=MY_API_KEY&callback=initMap">
</script>

Does anybody have any experience with this problem? Am I missing something simple? Thanks

Share edited Jul 12, 2018 at 13:52 xomena 32.2k6 gold badges96 silver badges125 bronze badges asked Jul 10, 2018 at 21:14 MattWolc24MattWolc24 1061 silver badge9 bronze badges 1
  • Which API did you activate in your project? The code that you posted requires a Google Maps JavaScript API be activated. – xomena Commented Jul 12, 2018 at 13:53
Add a ment  | 

1 Answer 1

Reset to default 9

Go to console.cloud.google. and follow the following steps:

1) APIs & Services

2) Dashboard

3) + Enable APIS and Services

4) Maps JavaScript API

5) hit Enable button

发布评论

评论列表(0)

  1. 暂无评论