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 }),

But what happens is, that all my features disappear. Do I have to redraw them? I should be so simple.


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:

let style = new ol.style.Style({
            image: new ol.style.Circle({ // add this
              stroke: new ol.style.Stroke({
                color: '#ff00ff'
              radius: 5

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.