【发布时间】:2019-12-14 19:30:57
【问题描述】:
Google 地图仅在 chrome 浏览器中获取“initMap 不是函数”。
在其他浏览器(Firefox、IE 等)中运行良好。
我正在使用 Google MAP API 进行位置搜索和自动完成位置。
我尝试过的类似问题的答案。 (https://stackoverflow.com/questions/46319676/initmap-is-not-a-function-in-using-google-maps-api),(https://stackoverflow.com/questions/40448238/initmap-is-not-a-function) 尚未在 Chrome 中运行。
这里是代码。
<script>function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
center: { lat: 34.397, lng: 150.644 },
scrollwheel: false,
zoom: 2
});
}
</script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key={{KEY}}&callback=initMap">
</script>
<div>
<div id="map" style="width: 500px; height: 400px;"></div>
</div>
【问题讨论】:
-
发布的代码在 Chrome (fiddle) 中对我来说很好用。请发布 minimal reproducible example 来证明您的问题
标签: javascript html google-maps google-chrome google-maps-api-3