1

Can I get legend with multiple layers using GetLegendGraphic on GeoServer?

It works fine for 1 layer and suppose to work for layer group according to this documentation https://www.geosolutionsgroup.com/blog/developers-corner-geoserver-getlegendgraphic-enhancements/ but I am getting an error that layer does not exist if I add name of layer group.

http://geoservername/geoserver/wms?REQUEST=GetLegendGraphic&VERSION=1.0.0&FORMAT=image/png&WIDTH=20&HEIGHT=20&LAYER=testgroup

Are there some specific settings for the layer group that I need to add?

1 Answer 1

2

The default GeoServer data directory comes with a couple of configured layer groups. I had a test with the "spearfish" group.

http://localhost:8080/geoserver/wms?service=WMS&version=1.1.0&request=GetLegendGraphic&layer=spearfish&format=image/png

It seems to be possible to get a legend for a layer group. I noticed that you used WMS version 1.0.0 in the request. GeoServer does not support it, but it seems that with this request it does not care. I also noticed that &WIDTH and &HEIGHT behave in some odd way with a layer group. However, you have not managed to get so far yet. I suggest to compare your layer group configuration with the GeoServer demo layer group.

enter image description here

1
  • Thanks, your idea helped to resolve my issue. I had problem with the assigned workspace name in my layer group. But I didn't include it is the link. Commented Feb 7 at 14:45

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.