Google地图获取"initMap不是函数";仅在Chrome浏览器中 [英] Google map getting "initMap is not a function" in chrome browser only

查看:255
本文介绍了Google地图获取"initMap不是函数";仅在Chrome浏览器中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Google地图仅在chrome浏览器中获得"initMap不是函数".

Google map getting "initMap is not a function" in chrome browser only.

在其他浏览器(Firefox,IE等)中工作正常.

In other browsers (Firefox, IE, etc ) are working fine.

我正在使用Google MAP API进行位置搜索和自动完成位置.

I am using the Google MAP API for location search and autocomplete location.

我尝试过的类似问题的答案. (

The similar question answers I had tried. (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) Not working yet in 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&amp;sensor=false"></script>
$(document).ready(function() {
    ...
    google.maps.event.addDomListener(window, 'load', initMap);
});

这篇关于Google地图获取"initMap不是函数";仅在Chrome浏览器中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆