Select 互动:仅在点击功能时切换

Select interaction: toggle only when clicking feature

我设置了一个带有单个矢量图层的 ol3 地图,其中的特征由 type 属性区分。我添加了一个 select 交互,只有 selects/unselects 具有 type == 'cp' 的功能。到目前为止我有:

selectInteraction = new ol.interaction.Select({
    condition: ol.events.condition.click,
    filter: function (feat, layer) {
        return (feat.get('type') == 'cp');
    }
});

我现在想要的是:

请帮助实现此行为。

将以下内容添加到 select 交互的选项中可以实现所需的行为:

toggleCondition: function (mbe) {
    return (mbe.type == 'click');
}