我试图使用angular-google-maps启动谷歌地图 但是,我有这些错误,尽管我已按照quickstart页面上的指南进行操作
所以我谷歌的错误,但我什么都没有,但我看到一些类似的问题,它由AdBlock引起,所以我使用隐身窗户再次测试,这些错误消失但谷歌地图仍然不在我的应用程序
这是我的完整代码
master.html (包含所有src)
<script type="text/javascript" src="/static/javascripts/lodash.js"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.js"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular-sanitize.min.js"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular-animate.min.js"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular-messages.min.js"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular-aria.min.js"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular-resource.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.13/angular-ui-router.min.js"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/angular_material/0.8.2/angular-material.min.js"></script>
<script type="text/javascript" src="//cdn.jsdelivr.net/satellizer/0.9.4/satellizer.min.js"></script>
<script type="text/javascript" src="/static/javascripts/angular-google-maps.js"></script>
<script type="text/javascript" src="/static/javascripts/loading-bar.js"></script>
app.js [angular.js]
var app = angular.module('app',['ngMaterial','ngSanitize','ngAnimate','satellizer','ngResource','ui.router','ngMessages','angular-loading-bar','uiGmapgoogle-maps']).
config(['$stateProvider','$urlRouterProvider','$authProvider','$locationProvider','$mdThemingProvider','cfpLoadingBarProvider','uiGmapGoogleMapApiProvider', function($stateProvider,$urlRouterProvider,$authProvider,$locationProvider,$mdThemingProvider, cfpLoadingBarProvider, uiGmapGoogleMapApiProvider) {
uiGmapGoogleMapApiProvider.configure({
// key: 'your api key',
v: '3.17',
libraries: 'weather,geometry,visualization'
});
$stateProvider
.state('home', {
url: '/',
templateUrl: '/static/views/index.html',
controller: 'IndexCtrl'
})
.
.
.
controller.js [angular.js]
angular.module('app').controller('IndexCtrl', [
'$scope',
'$http',
'$rootScope',
'$auth',
'Account',
'uiGmapGoogleMapApi',
function ($scope, $http, $rootScope,$auth,Account,uiGmapGoogleMapApi) {
uiGmapGoogleMapApi.then(function(maps) {
$scope.map = { center: { latitude: 45, longitude: -73 }, zoom: 8 };
});
}
]);
的index.html
<div style="width:500px;height:500px;">
<ui-gmap-google-map center='map.center' zoom='map.zoom'></ui-gmap-google-map>
{{map.center}}
</div>
{{map.center}}能够显示但不能显示地图。
答案 0 :(得分:0)
您可能尚未启动基本GoogleMap API
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=API_KEY">
</script>
答案 1 :(得分:0)
也许您需要“引导”Google Maps API。我通常在HTML中使用它,而不是使用ng-app
:
<script type="text/javascript">
// Manually bootstrapping method instead of ng-app="myApp" to be sure
// Google API Library is downloaded before Angular compiles the root page "/"
function onGoogleReady() {
angular.bootstrap(document, [ 'myApp' ]);
}
function loadScript() {
var script = document.createElement('script');
script.type = "text/javascript";
script.src = "https://maps.googleapis.com/maps/api/js?v=3&libraries=places&callback=onGoogleReady";
document.body.appendChild(script);
}
window.onload = loadScript();
</script>
答案 2 :(得分:-1)
我只是在这里猜测,但你试过这种方式吗?
<ui-gmap-google-map center='{{map.center}}' zoom='{{map.zoom}}'></ui-gmap-google-map>