angularjs 1.3的AngularMaps导致“TypeError:undefined不是一个函数”

angularjs 1.3的AngularMaps导致“TypeError:undefined不是一个函数”,angularjs,google-maps-api-3,angular-google-maps,Angularjs,Google Maps Api 3,Angular Google Maps,我已经使用该模块实现了一个非常基本的映射。在页面处理完所有脚本后,我总会发现一个TypeError:undefined不是Chrome开发者工具控制台中记录的函数,尽管一切似乎都按照预期工作 当$scope.control.getGMap.fitBounds$scope.bounds;在uiGmapIsReady承诺函数中调用 angular.module('app', ['uiGmapgoogle-maps']) .config(function (uiGmapGoogleMapApiPr

我已经使用该模块实现了一个非常基本的映射。在页面处理完所有脚本后,我总会发现一个TypeError:undefined不是Chrome开发者工具控制台中记录的函数,尽管一切似乎都按照预期工作

当$scope.control.getGMap.fitBounds$scope.bounds;在uiGmapIsReady承诺函数中调用

angular.module('app', ['uiGmapgoogle-maps'])


.config(function (uiGmapGoogleMapApiProvider) {
    uiGmapGoogleMapApiProvider.configure({
        //    key: 'your api key',
        v: 3.17,
        libraries: 'weather,geometry,visualization'
    });
})

.controller('MainController', ['$scope', '$timeout', 'uiGmapGoogleMapApi', 'uiGmapIsReady', function ($scope, $timeout, uiGmapGoogleMapApi, uiGmapIsReady) {

    $scope.markers = [
        { latitude: 33.970675, longitude: -118.454618},
        { latitude: 33.980675, longitude: -118.454618},
        { latitude: 33.974246, longitude: -118.455458}
    ]

    uiGmapGoogleMapApi.then(function (maps) {
        $scope.bounds = new maps.LatLngBounds();
        angular.forEach($scope.markers, function (value, key) {
            var myLatLng = new maps.LatLng($scope.markers[key].latitude, $scope.markers[key].longitude);
            $scope.bounds.extend(myLatLng);
        });
        $scope.map = { center: { latitude: $scope.bounds.getCenter().lat(), longitude: $scope.bounds.getCenter().lng() }, zoom: 5 };
        $scope.map.options = { MapTypeId: maps.MapTypeId.HYBRID };

    });

    $scope.control = {};

    uiGmapIsReady.promise().then((function (maps) {
        $scope.control.getGMap().fitBounds($scope.bounds);
    }));

    $scope.refreshMap = function () {
        $scope.control.refresh({ latitude: $scope.bounds.getCenter().lat(), longitude: $scope.bounds.getCenter().lng() });
    }

    $scope.streetZoom = function () {
        $scope.control.getGMap().setZoom(14);
    }
}])
这是标记

    <ui-gmap-google-map 
        center="map.center" 
        zoom="map.zoom" 
        options="map.options"
        control="control">
        <ui-gmap-marker idkey="$index" coords="item" ng-repeat="item in markers track by $index">
            <ui-gmap-window options="windowOptions" closeclick="closeClick()">
                <p class="google-window">{{item.latitude}}, {{item.longitude}}</p>
            </ui-gmap-window>
        </ui-gmap-marker>
    </ui-gmap-google-map>

任何关于为什么会发生这种情况的见解都将不胜感激!我觉得我好像弄坏了什么东西,不知道为什么。

我相信这就是getGMap未定义的地方,$scope.control.getGMapDo你有什么plnkr/fiddle吗?我已经解决了问题。在index.html中,我设置了ng controller=MainController属性。我还在一个单独的文件中配置了路由。这导致控制器在引导和路由配置上加载。我从标记中去掉了ng控制器属性,现在一切都正常了。
TypeError: undefined is not a function             angular.js:11655