【发布时间】:2017-03-28 01:07:44
【问题描述】:
GoogleMap 在我的 Angular 项目 (WebStorm IDE) 中不可见!!
我尝试过使用回调函数!!谷歌地图仍然不可见! I get this Error in Console
index.html
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAANu_sjcxDH04GZHg187EGg6csTeiX-jw&callback=initMap"
defer></script>
MapCtrl.js
.controller('MapCtrl',function ($scope, $window) {
$window.initMap = function () {
var map=new google.maps.Map(document.getElementById('map'), {
center: {lat: -34.397, lng: 150.644},
zoom: 8
});
}
});
Mymap.html
<div id="map" ng-controller="MapCtrl"></div>
【问题讨论】:
-
它应该像 initMap() insted of initMap 那样调用
-
我应该在哪里添加 initMap() ?我厌倦了添加脚本标签!它在控制台中抛出“加载资源失败:服务器响应状态为 400 ()”
-
确保您的谷歌地图没有错误
-
在这个链接中,他们没有给出initMap()——回调函数developers.google.com/maps/documentation/javascript/tutorial
标签: javascript angularjs google-maps-api-3