Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 第二次加载google map api失败_Angularjs_Google Maps_Google Maps Api 3_Ionic - Fatal编程技术网

Angularjs 第二次加载google map api失败

Angularjs 第二次加载google map api失败,angularjs,google-maps,google-maps-api-3,ionic,Angularjs,Google Maps,Google Maps Api 3,Ionic,我正在学习AngularJS和Ionic,并将谷歌地图API v3添加到我的应用程序中 这是我的控制器: $scope.drawMap = function(position) { $scope.$apply(function() { $scope.abc.lng = resp.data[0].longit; $scope.abc.lat = resp.data[0].latit; $scope.map = { ce

我正在学习AngularJS和Ionic,并将谷歌地图API v3添加到我的应用程序中

这是我的控制器:

$scope.drawMap = function(position) {
    $scope.$apply(function() {
        $scope.abc.lng = resp.data[0].longit;
        $scope.abc.lat = resp.data[0].latit;
        $scope.map = {
            center: {
                latitude: $scope.abc.lat,
                longitude: $scope.abc.lng
            },
            zoom: 17
        };
        $scope.marker = {
            id: 0,
            coords: {
                latitude: $scope.abc.lat,
                longitude: $scope.abc.lng
            }
        };
        $scope.marker.options = {
            draggable: false,
            labelAnchor: "80 120", //marker position
            labelClass: "marker-labels"
        };
    });
}
navigator.geolocation.watchPosition($scope.drawMap);
 $scope.$on('$ionicView.leave', function(){
   map.remove();
 });
})); })

这是我的HTML:

<ui-gmap-google-map center='map.center' zoom='map.zoom' events="map.markersEvents">
    <ui-gmap-marker coords="marker.coords" options="marker.options" idkey="marker.id">
    </ui-gmap-marker>
</ui-gmap-google-map>
resp.data
有一个
latlng
地址列表,我可以在进入该页面时加载地图


但是,当我返回到最后一页并选择另一个地址时,它无法加载我可以
控制台的映射。记录
它的
latlng

请注意,在您发布的代码中存在语法错误(不匹配闭括号)。确保您的完整代码中没有错误。谢谢!修复了语法错误。离开映射时需要调用map.remove()。谢谢!但离开时如何调用map.remove。我在控制器($scope.$on)上添加了“ionic view.cycle”,但仍然无法解决问题
starter.directive('googleMap', function(){
    return {
        templateUrl:"templates/google-map.html",
        link: function(scope, ele, attrs){

        }
    }
})