I am using GeoServer to serve up OSM data. I am making use of the GetLegendGraphic command, but I do not want some of my styles to appear in the legend (for example, the styles that are ONLY for text labels should not get a line).

Is there any way to specify that a style NOT appear in a legend?

  • In case it helps the use-case any, here is the situation. Using the OSM styles, there are styles defined for each road type for multiple scales [ex. 0-10k, 10k-40k, 40k-100k]. There are separate rules for the text labels on those roads for two scales [0-20k, 20k-50k]. The un-usable solution to this is to basically multiply those two and merge them [0-10k, 10k-20k, 20k-40k, 40k-50k], but that does not make the code maintainable and adds a lot of redundancy. – Zach Jun 4 '12 at 14:01

Zach, correct, there is no way to hide a rule from the GetLegendGraphics call. The SLD standard does not provide a way either, so someone would have to come up with an extension to the standard and then code to implement it at the Geotools and GeoServer level.


did you check GetLegendGraphic parameters in here. i didnt try something about your needs but i have used SCALE parameter eliminating internal rules that are out-of-scope.

&SCALE= 10000

maybe defining some rules give you what you want...

Rule of style to produce legend graphic for, if applicable. In the case that a style has multiple rules but no specific rule is selected, then the map server is obligated to produce a graphic that is representative of all of the rules of the style.

and you can check out this too..

i hope it helps you...

  • I was familiar with scale, but not with the rule command. Still, it doesn't quite fix the problem [unless, I guess, we have a GetLegendGraphic call for each of the non-text styles]. I'm pretty sure this is one of those things that just isn't supported. – Zach Jun 4 '12 at 14:01

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.