In Openlayers 3 how to remove a event listener attached like this:
var a = map.on("pointerdrag",function (e) {
// event handler
});
var b = map.on("pointerdrag",function (e) {
// event handler
});
How do I remove only listner a
and keep b
active?
.un
, if you are using a named function.function onPointerDragOne() {/*do stuf*/}
function onPointerDragTwo() {/*do stuf*/}
map.on("pointerdrag", onPointerDragOne);
map.on("pointerdrag", onPointerDragTwo);
map.un("pointerdrag", onPointerDragOne);
// Only onPointerDragTwo will run
– Pathoneurosis