I am trying to set the style of open layer by passing in an object but it is throwing error and when object is passed in an array then it works. Why isn't it letting me pass an object?

The code below throws assertion error 41 and when object is wrapped in an array it sets the style. The signature of setStyle is :

    setStyle(style: (ol.style.Style | ol.style.Style[] | ol.FeatureStyleFunction | ol.StyleFunction)): void;

 * Sets the style of this layer to "active"
setActiveStyle() {
    this.setStyle(new ol.style.Style({
        fill: new ol.style.Fill({
            color: 'rgba(255, 255, 255, 0.2)'
        stroke: new ol.style.Stroke({
            color: '#ff00de',
            width: 5
        image: new ol.style.Icon({
            anchor: [0.5, 1],
            src: this.pinkPinUrl

Your Answer

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

Browse other questions tagged or ask your own question.