gpt4 book ai didi

javascript - 谷歌地图未显示在页面中

转载 作者:行者123 更新时间:2023-11-28 17:59:28 25 4
gpt4 key购买 nike

已经有我的 id="ieatmaps" 来调用 googlemaps.js。但有些它没有被显示。也许我做错了什么。

      function initMap() {
var map = new google.maps.Map(document.getElementById('ieatmaps'), {
center: {lat: 40.674, lng: -73.945},
zoom: 12,
styles: [
]

});
}
.ieatmaps {
border:0;
height: 100%;
width: 200px;
}
<section id="map">
<div id="ieatmaps"></div>
<script src="js/googlemaps.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyB-aH4ym18aYYe86IiamWV88X-JrVhFLt8&callback=initMap"
async defer></script>
</section>

最佳答案

#ieatmaps 不是一个类

function initMap() {
var map = new google.maps.Map(document.getElementById('ieatmaps'), {
center: {lat: 40.674, lng: -73.945},
zoom: 12,
styles: [
]

});
}
#ieatmaps {
height: 200px;
width: 200px;
border:1px solid #000;
}
<section id="map">
<div id="ieatmaps"></div>
<script src="https://maps.googleapis.com/maps/api/js?sensor=false&key=AIzaSyB-aH4ym18aYYe86IiamWV88X-JrVhFLt8&callback=initMap"
async defer></script>
</section>

关于javascript - 谷歌地图未显示在页面中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43838338/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com