Javascript initMap不是函数:错误
谷歌地图在我的angular项目(WebStorm IDE)中不可见 我试过使用回调函数!!谷歌地图仍然不可见!!Javascript initMap不是函数:错误,javascript,angularjs,google-maps-api-3,Javascript,Angularjs,Google Maps Api 3,谷歌地图在我的angular项目(WebStorm IDE)中不可见 我试过使用回调函数!!谷歌地图仍然不可见!! index.html <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAANu_sjcxDH04GZHg187EGg6csTeiX-jw&callback=initMap" defer></script> })) Mymap.html <div
index.html
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAANu_sjcxDH04GZHg187EGg6csTeiX-jw&callback=initMap"
defer></script>
}))
Mymap.html
<div id="map" ng-controller="MapCtrl"></div>
尝试在地图id中添加一些css样式,我经常遇到这种情况
html, body { height: 100%; margin: 0; padding: 0; }
#map { height: 100%; }
如果您需要更多信息,请阅读我曾经遇到过同样的问题。我通过从src url的末尾删除“&callback=initMap”来解决这个问题。就你而言
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAANu_sjcxDH04GZHg187EGg6csTeiX-jw"
defer></script>
而不是
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAANu_sjcxDH04GZHg187EGg6csTeiX-jw&callback=initMap"
defer></script>
它应该像initMap()一样调用,而不是像initMap一样调用。我应该在哪里添加initMap()?我厌倦了添加脚本标签!它在控制台中抛出“加载资源失败:服务器响应状态为400()”。确保您的google地图没有错误检查:在这个链接中,他们没有给出initMap()--对于回调函数,我厌倦了所有的解决方案!!我还是犯了同样的错误**initMap--已替换并尝试initMap()**请尝试以下操作
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAANu_sjcxDH04GZHg187EGg6csTeiX-jw&callback=initMap"
defer></script>