The WMS standard provides a way of getting a legend for a layer, called GetLegendGraphic. For simple legends - those with one point symbol, one line symbol, or one polygon symbol, it works well. For example: Airports - the layer name massgis:GISDATA.AIRPORTS_PT and the style GISDATA.AIRPORTS_PT::Default http://giswebservices.massgis.state./geoserver/wms?VERSION=1.1.0&REQUEST=GetLegendGraphic&LAYER=massgis:GISDATA.AIRPORTS_PT&STYLE=GISDATA.AIRPORTS_PT::Default&WIDTH=16&HEIGHT=16&FORMAT=image/png&SERVICE=WMS or (ACECS, different styles): (brown hatch) http://giswebservices.massgis.state./geoserver/wms?VERSION=1.1.0&REQUEST=GetLegendGraphic&LAYER=massgis:GISDATA.ACECS_POLY&STYLE=GISDATA.ACECS_POLY::Default&WIDTH=16&HEIGHT=16&FORMAT=image/png&SERVICE=WMS (solid green fill) http://giswebservices.massgis.state./geoserver/wms?VERSION=1.1.0&REQUEST=GetLegendGraphic&LAYER=massgis:GISDATA.ACECS_POLY&STYLE=GISDATA.ACECS_POLY::Green_Fill&WIDTH=16&HEIGHT=16&FORMAT=image/png&SERVICE=WMS The SLD can come from a remote file: (SLD file is not there, syntax example) http://giswebservices.massgis.state./geoserver/wms?VERSION=1.1.0&REQUEST=GetLegendGraphic&LAYER=massgis:GISDATA.AIRPORTS_PT&SLD=http://maps.massgis.state./misc/black_points.sld.xml&WIDTH=16&HEIGHT=16&FORMAT=image/png&SERVICE=WMS For a more complicated layer, GeoServer's GetLegendGraphic is not there yet: Take the massgis:COUNTIES_POLY layer for example. An
attempt to get the legend though, provides color swatches only, no text
with which to distinguish the color meanings. (NOTE: I set HEIGHT to
200 pixels here, in order to get all the colors.) http://giswebservices.massgis.state./geoserver/wms?VERSION=1.1.0&REQUEST=GetLegendGraphic&LAYER=massgis:GISDATA.COUNTIES_POLY&STYLE=GISDATA.COUNTIES_POLY::Default&WIDTH=16&HEIGHT=200&FORMAT=image/png&SERVICE=WMS To get a legend swatch for one rule, the rule can be specified in the URL: http://giswebservices.massgis.state./geoserver/wms?VERSION=1.1.0&REQUEST=GetLegendGraphic&LAYER=massgis:GISDATA.COUNTIES_POLY&STYLE=GISDATA.COUNTIES_POLY::Default&RULE=Barnstable&WIDTH=16&HEIGHT=16&FORMAT=image/png&SERVICE=WMS Currently there is no XML format request to get a legend.
|