5

is there a possibility to add a second image to this openLayers 3 style?

My code looks as follows:

var klass_red
klass_red = new ol.style.Style({
  image : new ol.style.Circle({
    radius : 11,
    stroke : new ol.style.Stroke({
      color : '#980000',
      width : 3
    })
  }),
  stroke : new ol.style.Stroke({
    color : '#980000',
    lineDash : null,
    width : 3
  }),
});
6

As bartvde said, an array of styles is the way to go.

Here is how it would look like with your code (not tested):

const firstStyle = new ol.style.Style({
    image : new ol.style.Circle({
        radius : 11,
        stroke : new ol.style.Stroke({
           color : '#980000',
           width : 3
       })
    })
});
const secondStyle = new ol.style.Style({
    stroke : new ol.style.Stroke({
        color : '#980000',
        lineDash : null,
        width : 3
    })
});
const klass_red = [firstStyle, secondStyle];

And then use the array of styles like any other style, both will be applied.

2

Use an array of ol.style.Style objects

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

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.