This endpoint provides the legend of a given layer in the form of HTML markup. A legend is what is shown when you click the info button on a layer in the map viewer. It contains a description of the layer, the actual legend explaining the meaning of the different colors and symbols, and additional metadata.
To interact with the legend endpoint, you need to provide specific parameters in your request. These parameters are divided into Path Parameters, which are required and part of the URL, and Query Parameters, which are optional and modify the behavior of the request.
| Parameters | Description |
|---|---|
| layerBodId (required) | The technical name or the layer ID. |
| Parameters | Description |
|---|---|
| lang (optional) | The language. Supported values: de, fr, it, rm, en. (Defaults to de if browser language does not match any of the possible values) |
| callback (optional) | The name of the callback function. |
The endpoint returns an HTML document containing the legend for the specified layer. The response includes:
- A
titleandabstractdescribing the layer. - A
legend imageshowing the symbology used in the layer. - Additional
metadatasuch as the layer ID, valid scale range, and links to detailed descriptions, metadata, and data sources.
No CSS styling is applied by default, allowing you to integrate the legend seamlessly into your own application or website. You can style the HTML response using your custom CSS to match your application's design.
Get the legend for ch.bafu.nabelstationen:
<ExampleCodeBlock request="curl https://api3.geo.admin.ch/rest/services/api/MapServer/ch.bafu.nabelstationen/legend" exampleLang='html' example='
Nationales Beobachtungsnetz für Luftfremdstoffe NABEL: Stationen (Bundesamt für Umwelt BAFU)
Das Nationale Beobachtungsnetz für Luftfremdstoffe NABEL misst die Luftverschmutzung an 16 Standorten in der Schweiz. Die Stationen sind über das ganze Land verteilt und messen die Belastung an typischen Standorten (z.B. Strassen in Stadtzentrum, Wohngebiet, ländliche Station).Die Stationen des NABEL repräsentieren je nach Standorttyp unterschiedliche Belastungssituationen. Die Luftqualität muss somit nach Standorttyp und nicht nach geografischer Lage der Stationen beurteilt werden.
Legende
Informationen
| ID Geobasisdatensatz | 121.1 |
| Gültiger Massstabsbereich | - |
| Metadaten | Link zu geocat.ch |
| Detailbeschreibung | Link zur Detailbeschreibung |
| Datenbezug | Link für Datenbezug |
| Thematisches Geoportal | Link zum Fachportal |
| WMS Dienst | Link zum WMS |
| Datenstand | 01.01.2021 |
Get the same legend using JSONP:
$ curl https://api3.geo.admin.ch/rest/services/api/MapServer/ch.bafu.nabelstationen/legend?callback=callback