I'd like to cause an ol.interaction.Select obj to 'select' a feature when the user clicks on a button which is related to that feature. I'd like to be able to reuse the event handling code I already use for when a user clicks on a feature.
Is there a way to do this with the Select interaction?
<!-- UPDATE -->
Maybe when this PR get merged we can dispatch select
event. About reusing code, I guess you can solve this wrapping it on a function, and when push a feature to the collection, call your function with that feature.
<!-- End of update -->
Get the ol.interaction.Select
collection and push
or pop
as you want:
var select = new ol.interaction.Select({
//some options
});
map.addInteraction(select);
var collection = select.getFeatures();
collection.push(some_feature);
//or push an array of features
collection.extend(some_array_features);
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments