Google 地图仅在 chrome 浏览器中获取 "initMap is not a function"
Google map getting "initMap is not a function" in chrome browser only
Google 地图在 chrome 浏览器中获取 "initMap is not a function"。
在其他浏览器(Firefox、IE 等)中工作正常。
我正在使用 Google 地图 API 进行位置搜索和自动完成位置。
类似的问题我都试过了。 (
尚未在 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>
使用这个
<script
src="http://maps.googleapis.com/maps/api/js?v=3&sensor=false"></script>
$(document).ready(function() {
...
google.maps.event.addDomListener(window, 'load', initMap);
});
脚本应该在下面的部分。它找不到 "map" div 因此会产生导致 "initMap is not a function" 问题的问题。
<html>
<head></head>
<body>
<div>
<div id="map" style="width: 500px; height: 400px;"></div>
</div>
<script>
// scripts goes here
</script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key={{KEY}}&callback=initMap">
</script>
</body>
</html>
Google 地图在 chrome 浏览器中获取 "initMap is not a function"。
在其他浏览器(Firefox、IE 等)中工作正常。
我正在使用 Google 地图 API 进行位置搜索和自动完成位置。
类似的问题我都试过了。 ( 尚未在 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>
使用这个
<script
src="http://maps.googleapis.com/maps/api/js?v=3&sensor=false"></script>
$(document).ready(function() {
...
google.maps.event.addDomListener(window, 'load', initMap);
});
脚本应该在下面的部分。它找不到 "map" div 因此会产生导致 "initMap is not a function" 问题的问题。
<html>
<head></head>
<body>
<div>
<div id="map" style="width: 500px; height: 400px;"></div>
</div>
<script>
// scripts goes here
</script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key={{KEY}}&callback=initMap">
</script>
</body>
</html>