3

The GetLegendGraphic request works well. I display the legend at a fixed position in my viewer using OpenLayers. But I would like to know if there is any way to add some custom text to the legend.

The legend that geoserver produces is like this: http://docs.geoserver.org/latest/en/user/_images/samplelegend.png

But I need to produce a legend with a title: http://minus.com/m4AP102Jj

Does anyone know if the GetLegendGraphic request in GeoServer, or the SLD style have a way to add this?

UPDATE (23/08/12)

For now I´ll use a litle trick to add a title by adding in my SLD another custom rule above all others that not match any other rules:

Example:

<sld:Rule>
  <sld:Name>[NAME]</sld:Name>
    <sld:Title>[TITLE]</sld:Title>
    <ogc:Filter>
      <ogc:PropertyIsEqualTo>
        <ogc:PropertyName>[PROPERTY_NAME]</ogc:PropertyName>
        <ogc:Literal>[SOME_VALUE_THAT_NOT_MATCH_OTHER_RULES]</ogc:Literal>
      </ogc:PropertyIsEqualTo>
    </ogc:Filter>
    <sld:PolygonSymbolizer>
      <sld:Fill>
        <sld:CssParameter name="fill">[MATCH_BACKGROUND_COLOR]</sld:CssParameter>
      </sld:Fill>
    </sld:PolygonSymbolizer>      
</sld:Rule>
1

http://osgeo-org.1560.n6.nabble.com/Legend-Title-tc4987789.html#none

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

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.