[GIS] Click and Double click, deselect interaction OpenLayers 3

openlayers

I have tow ol.interaction.Select, one to the single click and the other one to double click.

var selectDoubleClick = new ol.interaction.Select({
    multi: true,
    condition: ol.events.condition.doubleClick,
    style: function(feature) {
        //stuff here;
    }
    return feature;
}

selectDoubleClick.on('select',function(event) {
    //stuff here
}

var selectSingleClick = new ol.interaction.Select({
    multi: true,
    condition: ol.events.condition.singleClick,
    style: function(feature) {
        //stuff here
    }
    return feature;
}

selectSingleClick.on('select',function(event) {
    //stuff here
}

But when i want to deselect the double click, i have to click twice in the map. Is any way to deselect in double click with just one click?

Best Answer

My solution was simple. First very if exists any getFeature link to this interaction (selectDoubleClick), and then clear this features.

var concludeClickEdit = function(eventListener) {
    if(selectDoubleClick.getFeatures().getLength() !== 0){
             selectDoubleClick.getFeatures().clear();
          }
}