I looked around quite a bit to find out the correct way to remove event listners in Cesium. I believe the confusion I have is around whether to treat Cesium events as regular DOM events or as Cesium specific ones (due to a lack of knowledge about events in general in javascript). I am creating a screen space event like below:
var handler = new Cesium.ScreenSpaceEventHandler(canvas);
handler.setInputAction(function (m) {
var picked = scene.pick(m.endPosition);
if (Cesium.defined(picked) && picked.id === someEntity) {
labelEntity.label.show = true;
} else {
labelEntity.label.show = false;
}
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
My question is, how can I remove this event listner? Does handler.destroy()
remove all the event listners associated with handler, or do I specifically have to remove event listners by pointing to the cesium map DOM element and calling removeEventListner
on it? If that’s the case, what parameters should be passed on to removeEventListner
?