2013-10-18 20 views
0

我正在使用尼古拉斯Laplante谷歌地圖(http://nlaplante.github.io/angular-google-maps/)模塊。通過座標時的中心財產異步調用我有問題:

這是我的控制器:

app.controller('baznaCtrl',function($scope,$routeParams,$http){ 
    $scope.idB=$routeParams; 
    $scope.latitude=0; 
    $scope.longitude=0; 
    $http.get('https://my web service/json/'+$scope.idB.lokid).success(function(data){ 
     $scope.bs=data; 
     $scope.latitude=$scope.bs.lattitude.replace(',','.'); 
     $scope.longitude=$scope.bs.longitude.replace(',','.'); 
    }); 

    angular.extend($scope,{ 
     center : { 
      latitude: $scope.latitude, 
      longitude:$scope.longitude 
     }, 
     markers:[], 
     zoom: 8 
    });  
}); 

看來,谷歌地圖不改變其中心屬性時,數據來自$http電話。它始終是0,0(因爲初始值爲$scope.latitude$scope.longitude)。

回答