Hi There,
I have an issue with using the parameter SLD in GetMap when using the WMS service via the geoserver's API. When passing a style into the parameters of a GET call to a WMS layer using the STYLES parameter I get the desired result. However, when I copy and paste the sld code into a file on GitHub and use the SLD parameter accordingly, everything is grey.
Any idea?
Geoserver version: 2.19.1
Using parameter styles: [https://stage.xcube-geodb.brockmann-consult.de/geoserver/eea-urban-atlas/wms?service=WMS&version=1.1.0&request=GetMap&layers=eea-urban-atlas%3Aeea-urban-atlas_SI001L2_LJUBLJANA_UA2018&bbox=4638735.0%2C2524481.25%2C4704972.5%2C2594978.75&width=721&height=768&srs=EPSG%3A3035&format=image/png&SLD=https://github.com/dzelge/test-gha/blob/main/ljubilana.sld?raw=true](https://stage.xcube-geodb.brockmann-consult.de/geoserver/eea-urban-atlas/wms?service=WMS&version=1.1.0&request=GetMap&layers=eea-urban-atlas%3Aeea-urban-atlas_SI001L2_LJUBLJANA_UA2018&bbox=4638735.0%2C2524481.25%2C4704972.5%2C2594978.75&width=721&height=768&srs=EPSG%3A3035&format=image/png&SLD=https://github.com/dzelge/test-gha/blob/main/ljubilana.sld?raw=true)
Using parameter SLD: [https://stage.xcube-geodb.brockmann-consult.de/geoserver/eea-urban-atlas/wms?service=WMS&version=1.1.0&request=GetMap&layers=eea-urban-atlas%3Aeea-urban-atlas_SI001L2_LJUBLJANA_UA2018&bbox=4638735.0%2C2524481.25%2C4704972.5%2C2594978.75&width=721&height=768&srs=EPSG%3A3035&styles=ljubilana&format=image/png](https://stage.xcube-geodb.brockmann-consult.de/geoserver/eea-urban-atlas/wms?service=WMS&version=1.1.0&request=GetMap&layers=eea-urban-atlas%3Aeea-urban-atlas_SI001L2_LJUBLJANA_UA2018&bbox=4638735.0%2C2524481.25%2C4704972.5%2C2594978.75&width=721&height=768&srs=EPSG%3A3035&styles=ljubilana&format=image/png)
Style: [https://github.com/dzelge/test-gha/blob/main/ljubilana.sld?raw=true](https://github.com/dzelge/test-gha/blob/main/ljubilana.sld?raw=true)
Thanks
I think you got your examples backwards?
The SLD parameter is used to pass a style that completely defines a map including listing all of the layers. To make this work your layers eea-urban-atlas etcc… should be documented as user layers in your SLD file.
Try removing the layers parameter, encode the SLD url value, and try again?
Actually checking the URL it redirects to https://raw.githubusercontent.com/dzelge/test-gha/main/ljubilana.sld … so using that:
The result is: Error while getting SLD. See the log for details.
I guess the next step is to check those logs.
For a working example testing locally https://localhost:8080/geoserver/wms?service=WMS&version=1.1.0&request=GetMap&SLD=http%3A%2F%2Flocalhost%3A8080%2Fgeoserver%2Fstyles%2Fnavigation.sld&bbox=-180.0,-90.0,180.0,90.0&width=768&height=384&srs=EPSG:4326&format=application/openlayers
This has no layers parameter listed in the URL, instead the map pulls its layers from a document like navigation.sld like:
<?xml version="1.0" encoding="UTF-8"?> ne:states_provinces_scale Administration Boundary #f0f0C0 #cccccc ne:roads Roads #AA3333···
–
Jody Garnett