angular-openlayers-directive icon indicating copy to clipboard operation
angular-openlayers-directive copied to clipboard

Moveend Event on a layer

Open evisms opened this issue 7 years ago • 2 comments

Hi! I would like to know how to listen to a zoom in-out and mouse move (center change) event on a layer, just to make a WMS request each time that happends. I tried the following code but it doesn't work:

$scope.$on('openlayers.layers.ccaa.moveend', function(event, feature){ .... });

Thanks

evisms avatar Feb 16 '17 09:02 evisms

Hey, something like this may work.

<!-- map.html -->
<openlayers ol-center="vm.center" ...>
</openlayers>

and in the controller

var component = {
   templateUrl: 'map.html',
   controller: MapController,
   controllerAs: 'vm'
};

function MapController($scope) {
   var vm = this;

   ...
   $scope.$watch('vm.center', function(newVal, oldVal) {
      var zoomLevel = newVal.zoom;
      var lat = newVal.lat;
      var lng = newVal.lon
   });
   
}

juristr avatar Feb 17 '17 07:02 juristr

Is there any solution with out using $watch?.

vamsikrishnamannem avatar Sep 07 '17 13:09 vamsikrishnamannem