Legend
From MapbenderWiki
User:Astrid Emde (Module maintainer)
Contents |
Description
english
Calls a getLegendGraphic URL and displays the image in a reserved window or frame.
Make sure, that your WMS Version and your MapServer supports the request getLegendGraphic (have a look at your getCapabilities-Request)
- OGC WMS supports the optional getLegendGraphic-request as of Version 1.1.0
Using MapServer
UMN MapServer Supports the getLegendGraphic request as of Version 4.0. To create a legend, first add a LEGEND-Block to the mapfile.
Example for UMN legend tag
LEGEND
STATUS ON
KEYSIZE 16 10
TRANSPARENT ON
LABEL
TYPE TRUETYPE
FONT 'arial'
SIZE 8
COLOR 1 1 1
END
END
For more details refer to: http://mapserver.gis.umn.edu/docs/reference/mapfile/legend
Make sure to add a NAME tag to every CLASS block item and layer that you want to be able to query by getLegendGraphic. Only those objects that have a NAME will be displayed.
How To
Add an iframe for the legend to your GUI.
- Target: mapframe1
- SRC: ../mapbender/http/javascripts/mod_legend.php?sessionID
To display the legend Mapbender starts getLegendGraphic requests for every layer of the wms.
Please modify the embedded legend.css to change the layout of the legend.
Example
Example for a getLegendGraphic request:
Notice
If you want to handle grouped layers you shouldn't check the function "sublayers_off" in "edit gui wms" (GUI WMS Einstellungen) for these layers.
Then the childs (=sublayers of a group) are known to the legend module in the client and thereby mapbender is able to request the legend from the single layers.
deutsch
Für jeden Layer wird ein getLegendGraphic-Request abgeschickt. Die zurückgelieferten Bilder werden in einem dafür angelegten Fenster oder IFrame angezeigt.
Unbedingt darauf achten, dass der WMS den Request getLegendGraphic unterstützt (Anzeige im getCapabilities-Aufruf).
Anwendung
- OGC WMS verfügt seit der Version 1.1.0 über die optionale Operation getLegendGraphic.
- Das Modul wird über das Anlegen eines IFrames namens legend eingebunden.
Die Ausgestaltung der Legende bestimmen Legendengraphik und das Stylesheet legend.css aus dem Mapbender /css-Ordner. - Target: mapframe1
- SRC: ../mapbender2/http/javascripts/mod_legend.php?sessionID
MapServer Anwendungsbeispiel
Der UMN MapServer bietet im WMS-Modus die Möglichkeit, ein Legenden-Objekt zu erzeugen. Hierzu muß in der Mapdatei nach dem Header-Bereich der Legend-Block angegeben werden. Außerdem muß jede CLASS, die in der Legende erscheinen soll, über die Angabe des Parameters NAME verfügen.
Beispiel für UMN Legend-tag:
LEGEND
STATUS ON
KEYSIZE 16 10
TRANSPARENT ON
LABEL
TYPE TRUETYPE
FONT 'arial'
SIZE 8
COLOR 1 1 1
END
END
Beispiel:
Hier ein Beispiel für einen getLegend Graphic-Request: http://wms1.ccgis.de/cgi-bin/mapserv?map=/data/umn/mapbender_user/mapbender_user.map&VERSION=1.1.1&REQUEST=GetLegendGraphic&LAYER=Mapbender_User&Format=image/png
Hinweis für gruppierte Layer
Bitte beachten Sie, dass das Modul mod_legend.php derzeit nur ungruppierte Layer ansprechen kann, da im Request der Layername angegeben werden muß (nicht der GROUP-Name). Raster-Layer geben beim getLegendGraphic-Request ebenfalls kein Image zurück.
Wenn Ihr WMS gruppierte Ebenen enthält, dürfen in der Administration unter "GUI WMS Einstellungen" (edit GUi WMS) die Haken unter "sublayer off" nicht entfernt werden.
Sind die Haken gesetzt sind die Sublayer im Legendenmodul bekannt und die Legendurl der einzelnen Layer wird angefordert.
Element Vars
checkbox _on_off: <description> / <Beschreibung>
css_file_legend: <description> / <Beschreibung>
legendlink: <description> / <Beschreibung>
showgroupedlayertitle: <description> / <Beschreibung>
showlayertitle: <description> / <Beschreibung>
showwmstitle: <description> / <Beschreibung>
stickylegend: <description> / <Beschreibung>
Files
For this module the following files are required / Für dieses Modul werden die folgenden Dateien benötigt:
SQL
Use this sql statement to insert this module in the corresponding gui / Mit diesem SQL kann das Modul in die entsprechende GUI eingefügen werden:
WMS Legend
- summary of the rules which are defined in the OGC Spec for WMS Version 1.1.0
WMS Request: getLegend
- WMS OGCv 1.1.1 page vii
7. For the use of the Styled Layer Descriptor specification, three new optional operations are named, but not otherwise specified, in this document (GetLegendGraphic, GetStyles, PutStyles).
- An SLD WMS adds the following additional operations that are not available on a basic
WMS: DescribeLayer
- GetLegendGraphic
- GetStyles
- PutStyles
- 7.5 GetLegendGraphic (SLD WMS only) - WMS OGCv 1.1.1 page 42
The optional GetLegendGraphic operation applies only to a Styled Layer Descriptor WMS. See the SLD specification [3] for this operation. NOTE: Change from version 1.1.0: This is a new operation.
legendurl
- LegendURL is optional and part of the Style-block (Zero or more Styles may be advertised for a Layer or collection of layers)
- <LegendURL> contains the location of an image of a map legend appropriate to the enclosing Style. (WMS OGCv 1.1.1 page 26)
- A <Format> element in LegendURL indicates the MIME type of the logo image
- A Map Server may use zero or more LegendURL elements to provide an
image(s) of a legend relevant to each Style of a Layer. The Format element indicates the MIME type of the legend. (WMS OGCv 1.1.1 page 46)
description of solution to handle legend-images with owsproxy
- this proposal is for discussion
- Facts
- Layers can have 0 or many styles
- Mapbender does not handle Styes at the moment (Version 2.4.2) the default-Style is choosed in every Request ( f.e. STYLE=,,,)
Suggestion for a Solution legend and owsproxy
- Mapbender has to learn to handle styles
- could be a new select-column for every layer (in edit gui wms), where the admin can choose a style for each layer
- Mapbender will use this style in the Maprequest
- maybe it would be good to provide to choose the default steyle and write STYLE=,,,,, as with many and "long-named" style-names the urls can get to long for the browser
- with owsproxy: Mapbender does not take the legend-url from the column legendurl from table layer_style. Instead Mapbender create a Legendurl like this:
- http://session/md5(wms)/layer_name/style=default/request=getLegendGraphic
- with this url owsporxy can go to the db and get the image-url

