I have a function that adds a Cesium event listener in a subscription. I would like to know how to remove it after use.
Here is my code :
this.layerService.visibilityChange.subscribe((layer){
viwer.scene.globe.tileLoadProgressEvent.addEventListener((count) => {
console.log(count);
if(viewer.scene.globe.tilesLoaded){
viewer.imageryLayers.pickImageryLayerFeatures(ray, scene);
}
})
})
After executing this code, the event is still console.log the count each times tiles are loaded. How can i remove it juste after the pickImageryLayerFeatures()
has executed ?
CodePudding user response:
In fact I have read the doc eheh, And Cesium tell us that tileLoadProgressEvent return a function that will remove this event listener when invoked.
CodePudding user response:
Just like addEventListener
you can also remove event listner.
viwer.scene.globe.tileLoadProgressEvent.removeEventListener(myFunction);