Reputation: 73
I would like to continue using the default toggle options of the interaction.Select, so the user can only have one feature selected at a time. However, when a user clicks outside of a feature, I do not want it to remove the currently selected feature. Is there a way to achieve this? Thank you in advance.
Upvotes: 2
Views: 1066
Reputation: 73
I was able to solve my problem with the following...
var select = new ol.interaction.Select({
style: vm.selectedFeatureStyle,
condition: function (event) {
if (event.type === 'singleclick') {
return vm.map.forEachFeatureAtPixel(event.pixel, function () {
return true;
});
}
return false;
}
});
Upvotes: 5