[GIS] Selecting feature and highlighting based on feature properties in OpenLayers 3

openlayers

I need to select link using link properties, I am able to find the feature but not able to highlight programmatically. please help..

In openlayers 2 we have selectFeature but not sure what is in ol3

Best Answer

@ahocevar's answer saved me hours but one thing is missing from the code is to add select interaction to map object:

var select = new ol.interaction.Select();
//make sure you add select interaction to map
map.addInteraction(select);
var features = select.getFeatures();
// now you have an ol.Collection of features that you can add features to
features.push(feature);
// now the pushed feature is highlighted

//to dehighlight, just simply remove the feature from select
features.remove(feature);