Why i'm unable to unbind event in openlayers 3?
I'm trying to draw circle interactivily.
For unbind event I'm using map.un('click',function(){ ... });
M.on('click',function(e){
if(!$pec.hasClass('active')) { deactive(true); return false;}
if( !isDrawing ){
isDrawing = true;
var center = e.coordinate;
var circle = new ol.geom.Circle([center[0],center[1]],10000,'XY');
var feature = new ol.Feature(circle);
var vectorSource = new ol.source.Vector();
vectorSource.addFeature(feature);
c = new ol.layer.Vector({
source: vectorSource
});
c.circle=circle;
M.addLayer(c);
$('body').css('cursor','crosshair');
}
else {
isDrawing = false;
deactive(false);
$('body').css('cursor','default');
finishDraw('circle',c);
}
});
M.on('pointermove',function(e){
if(isDrawing){
c.circle.setRadius(distanceTo(c.circle.getCenter(),e.coordinate));
}
});
function deactive(all){
M.un('click',function(){ log('deactive click');});
M.un('pointermove',function(){});
if(c && all) M.removeLayer(c);
isDrawing = false;
}
How to solve it ? I have more unbinds like this and all wont work -.-