[GIS] Combine multiple images in style of OpenLayers

openlayersstyle

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

Best Answer

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.

Related Question