How to disable the click event on the map? I'm trying to use map.un but it doesn't work. unByKey doesn't work
import unByKey
'unByKey' is declared but its value is never read.ts(6133)
Module '"/node_modules/@types/ol/Observable/index"' has no exported member 'unByKey'
Try it with a checkbox, the event is added to the map, but when I uncheck the checkbox and check the checkbox, it is duplicated
function onClickDetail(evt) {
console.log('Done');
};
if (isCheck)
{
map.on('singleclick',onClickDetail);
}
else
{
map.un('singleclick',onClickDetail);
}
after 5 time reactivate checkbox
You have to define the function onClickDetail
outside of your function AddWMSLayer
. Otherwise it will always be a new function "pointer" and the reference will be not the same.