I'm using the accepted answer from here to programatically select a feature on my map.
All ok, except that my custom select style is not applied (the element looks just like before).
I'm using this code to setup my Select
interaction:
var selectSingleOrDoubleClick = new ol.interaction.Select({
style: this.selectCustomStyle,
condition: function(mapBrowserEvent) {
return ol.events.condition.singleClick(mapBrowserEvent) || ol.events.condition.doubleClick(mapBrowserEvent);
},
filter: function(feature, layer) {
...
}
});
I'm doing this in order to programmatically select my feature:
selectSingleOrDoubleClick.getFeatures().clear();
selectSingleOrDoubleClick.getFeatures().push(featureToSelect);
selectControl.dispatchEvent({
type: 'select',
selected: [featureToSelect],
deselected: []
});
I should not that my feature IS considered
selected (for example if I select another feature via user interaction, my previously-selected feature becomes unselected, etc.