AnsweredAssumed Answered

How to simulate listening for zoom-end in the 4.x framework.

Question asked by sl5337 on Aug 27, 2018
Latest reply on Aug 27, 2018 by sl5337

I'm upgrading a current application from the 3.x framework to 4.x.  In the current application I listen for the zoom-end event in order to know when to enable/disable branches in my custom layer tree based on the defined min scale for each layer.  

 

I realize the new framework "makes it easier" to watch for changes in object properties with the watch method. The problem is that when the user is zooming in and out I do not want to execute a function on every change in the zoom level.  My layer tree has hundreds of branches.  I don't want to iterate through all of that data every time the zoom level changes while the user is spinning the mouse wheel.

 

I have found this as a workaround:

watchUtils.when(myMapView, "stationary", function() {
   
const currentScale = myMapView.get('scale'
));
   // now go through all of the layers and enable/disable based on the current scale...
});

The problem is that this event is fired when the user does other things such as panning the map.  I'm only interested in knowing when the user has finished zooming the map.

 

Does anybody have any ideas about this?  Maybe I have missed something in the documentation. Thanks for your help.

Outcomes