0

I have an Angular map app with a WMS layer initialized as following:

this.layer =
new ImageLayer({
  source: new ImageWMS({
    url: url,
    params: {LAYERS: this.getActiveLayers()},
    projection: proj
  })
});

this.map = new Map({
  target: 'map',
  layers: [this.layer],
  view: new View({
    projection: proj
  })
});

At some point I need to update the wms layer, so I create another ImageWMS with the new requirements

this.auxLayer =
new ImageLayer({
  source: new ImageWMS({
    url: url,
    params: {LAYERS: this.newLayers()},
    projection: proj
  })
});

How can I update the layer with the new auxLayer info?

2 Answers 2

2

You could simply update the params in the existing source

this.layer.getSource().updateParams({LAYERS: this.newLayers()});
0

Easily solved using this:

let source: new ImageWMS({
    url: url,
    params: {LAYERS: this.newLayers()},
    projection: proj
})

And then using the layer variable:

this.capaPropia.setSource(source);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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