我想用谷歌地圖做一個應用程序,但是,似乎我錯過了一些東西。谷歌地圖不加載 - Angular JS
這裏是我的代碼:
<div class="container-fluid" ng-app="mapApp" ng-controller="mapCtrl">
<div class="row">
<div class="container-fluid">
<div class="row header">
<ui-gmap-google-map center='map.center' zoom='map.zoom'>{{map}}</ui-gmap-google-map>
</div>
</div>
</div>
</div>
app.js:
'use strict';
// Declare app level module which depends on views, and components
angular.module('mapApp', [
'ngRoute'
]).config(['locationProvider', '$routeProvider', function($locationProvider, $routeProvider) {
$locationProvider.hashPrefix('!');
$routeProvider.otherwise({redirectTo: '/view1'});
}]);
.config(function(uiGmapGoogleMapApiProvider) {
uiGmapGoogleMapApiProvider.configure({
key: 'key',
v: '3.20', //defaults to latest 3.X anyhow
libraries: 'weather,geometry,visualization'
});
});
controller.js:
app.controller('mapCtrl', function($scope, uiGmapGoogleMapApi) {
//make magic
uiGmapGoogleMapApi.then(function(maps) {
$scope.map = { center: { latitude: 45, longitude: -73 }, zoom: 8 };
});
});
,我已經添加的風格:
.angular-google-map-container {
height: 400px; }
輸出似乎沒有很好地解析表達式,所以我只收到{{map}}
。
我已經失去了整整一天,試圖找出這一個..它可能是一些'小'我錯過了。請注意,在'鑰匙'下有一個合法的API密鑰。
請幫忙,謝謝。
非常感謝!我不相信我沒有分配依賴... –