2

I have a layer group called "basemap" in my GeoServer made up of 3 layers but their SLDs needs to be styled dynamically so I have decided to create a XML web service for the external SLDs but I am wondering whether I can pass multiple SLD files as shown below.

How do I go about it?

Please check my SLD parameter in my code below if that is how to do it.

Or should I stop using layer group and call the layers one by one and pass its external SLD link to it?

My Codes Below In OpenLayers

var getBasemap = function(){

    GlobalBasemapLayer = new OpenLayers.Layer.WMS(
        "Basemap",
        geoserverWMSurl,
        {   LAYERS: 'workspace:basemap',
            format: format,
            tiled: true,
            transparent:true,
            sld:'http://domain.com/getSLD/Layer1SLD,http://domain.com/getSLD/Layer2SLD,http://domain.com/getSLD/Layer3SLD'
        },
        {
            buffer: 0,
            displayOutsideMaxExtent: true,
            isBaseLayer: false
        }
    );
};

1 Answer 1

1

You can't do that, a layer group is internal to GeoServer. To the outside world (looking through the WMS endpoint) it is a single layer so you can attach just one SLD file (or style) to it. Since a client has no way of being able to determine the make up of a layer group it makes no sense to send SLD files to it and I suspect (but haven't checked) that there is no code implementing that path.

You need to break your layers out in the request so that each SLD file can be applied to the correct layer.

var getBasemap = function(){

    GlobalBasemapLayer = new OpenLayers.Layer.WMS(
        "Basemap",
        geoserverWMSurl,
        {   LAYERS: 'workspace:layer1,workspace:layer2,workspace:layer3',
            format: format,
            tiled: true,
            transparent:true,
            sld:'http://domain.com/getSLD/Layer1SLD,http://domain.com/getSLD/Layer2SLD,http://domain.com/getSLD/Layer3SLD'
        },
        {
            buffer: 0,
            displayOutsideMaxExtent: true,
            isBaseLayer: false
        }
    );
};

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.