angular-google-maps icon indicating copy to clipboard operation
angular-google-maps copied to clipboard

changing center by position of marker?

Open anatlerner opened this issue 10 years ago • 3 comments

hi Im trying to do the following action $scope.map.panTo($scope.marker.getPosition()); but $scope.map.panTo is not defined. what is the way to change center by position of marker?

 uiGmapGoogleMapApi.then(function(maps) {
               vm.map = {
                   center: {
                       latitude: $scope.config.lat || 32.0487335 ,
                       longitude: $scope.config.long || 34.7591261
                   }, 
                   zoom: 12 };
               vm.options = { scrollwheel: false };
               vm.marker = {
                   id: 0,
                   coords: {
                       latitude: $scope.config.lat,
                       longitude: $scope.config.long
                   }
               }

               $scope.$watch('vm.config', function(newConfig, oldConfig){
                   if (newConfig != oldConfig) {
                       //change center of map
                       $scope.map.panTo($scope.marker.getPosition());

                   }
               }, true);

anatlerner avatar Mar 08 '16 16:03 anatlerner

Ofcourse they are. Your using the same reference of data for both. The reference is mutable and if you change the values of it for the marker.. so center will change too.

nmccready avatar Mar 08 '16 16:03 nmccready

it doesn't work. how can i make it work?

anatlerner avatar Mar 08 '16 17:03 anatlerner

i can not get this work either. not panning to marker or zomming to marker!

goors avatar Oct 24 '16 08:10 goors