I created the function that enable selection of feature from map, with 2 functions thats are called when I click on feature or when I click on map (no feature selected)
E.G
select = new ol.interaction.Select({
toggleCondition: this.isMultipleSelectionEnable
? null
: ol.events.condition.never,
style: selectedStyle
})
this.select = select
map.addInteraction(select)
this.selectedFeatures = select.getFeatures()
Here are my functions
this.selectedFeatures.on(['add'] function() {} // add feature to map)
and
this.selectedFeatures.on(['remove']function(){this.map.clear())
This works well when I click on my map, but whenever I call the function clear() to clear selectedFeatures from another component, it automaticly calls the 'remove' function from OL, making an infinite loop.
How can I resolve this? How can we can we clear the selected features from the map, without triggering the "remove" function from OL? Or can we call directly the 'remove' from another component?