2

I have a TileWMS:

var mapWMSTile = new ol.source.TileWMS(
            {
                url: '.....',
                params: {'LAYERS': 'l1,l2', VERSION: '1.3.0', 'TILED': true},
                serverType: 'mapserver'
            });

        var fieldTile = new ol.layer.Tile(
            {
                source: mapWMSTile,
                name: 'fieldTile'
            });

Now I want to add a layers to my WMS parameters (e.g. add l3 in 'LAYERS'). Is this possible?

I have tried the below codes without success:

First try:

mapWMSTile.updateParams(
                {
                    params: {'LAYERS': 'l3', VERSION: '1.3.0', 'TILED': true}
                });

Second try:

fieldTile.getSource().updateParams({'LAYERS': 'l3', VERSION: '1.3.0', 'TILED': true});

I am using OpenLayers 3.9.0.

1 Answer 1

3
mapWMSTile.updateParams({
    'LAYERS': 'l3',
    'VERSION': '1.3.0',
    'TILED': true
});
6
  • I can't believe that I was missing ' in version.... Thank you Sep 23, 2015 at 21:55
  • 1
    @MenelaosKotsollaris The main issue with your code was not the ', but that the params were wrapped in another object (like the source constructor options). Sep 23, 2015 at 21:59
  • just noticed... that's what happens after 12h of programming.. ;/ Sep 23, 2015 at 22:01
  • by the way do you know any way of setting a specific bound to the view (e.g to show the map only between x1,y1 and x2,y2 ? Sep 23, 2015 at 22:10
  • Check out the extent option of the view. Sep 24, 2015 at 4:56

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.