After I have already displayed my map I want to highlight certain features.
For starters I am trying to highlight all features like this:
public highlightMapFeatures() {
this.map.getLayers().forEach(function (lyr) {
if (lyr.type === 'VECTOR') {
lyr.getSource().forEachFeature(function(feature) {
let style = new ol.style.Style({
stroke: new ol.style.Stroke({ color: '#ff00ff',
width: 2 }),
});
feature.setStyle(style);
}
});
But what happens is, that all my features disappear.
Do I have to redraw them? I should be so simple.
Best Answer
A stroke will not do for a dot shown on the map. It needs some kind of shape e.g. Circle. If we define the style like this, the features do not disappear: