【发布时间】:2019-05-13 19:21:36
【问题描述】:
我想在openlayers 3中同时单击和双击选择特征。创建ol.interaction.Select时的条件选项只需要一个功能,因此需要解决方法
我尝试编写自己的自定义条件函数来调用适当的函数,我正在考虑类似...
this.selectType = (feature) => {
if (feature){
if(feature.onclick){
return ol.events.condition.singleClick
} else {
return ol.events.condition.doubleClick
}
}
}
this.selectInteraction = new ol.interaction.Select({
condition: this.selectType(),
toggleCondition: ol.events.condition.shiftKeyOnly,
layers: this.layerFilter,
features: this.features,
style: this.selectStyle,
});
...但没有成功。
我意识到,我可以创建两个单独的交互来选择功能,但我宁愿不这样做,因为这将涉及根据 Select 交互复制大量代码。
有谁知道这在 openlayers 中是否可行,以及如何处理这种情况?
非常感谢
【问题讨论】:
标签: select onclick openlayers-3 double-click