/ui/layers/drawLegend
The module exports the drawLegend method which renders the legend for the current layer style theme.
- Source
Requires
Methods
(inner) drawLegend(layer)
The drawLegend method renders the legend for the current theme into the layer.style.legend node.
The legend method is resolved from the current layer.style.theme at execution time. The drawLegend reference is therefore stable across theme changes and is registered once as a layer.showCallbacks method in the layerStyle panel method.
The method will shortcircuit if the layer has no style.legend node to render into, or if no legend method is available for the current theme type.
The legend of a theme with a data distribution is not drawn until the distribution has been processed from the layer data. The legend would otherwise be drawn from every category in the theme configuration, creating icons for categories which are not in the data. The featureFields.process method calls drawLegend once the data has been received.
| Name | Type | Description |
|---|---|---|
layer | layer | A decorated mapp layer with a style object. |
| Name | Type | Attributes | Description |
|---|---|---|---|
layer.style | layer-style | The layer style configuration. | |
style.legend | HTMLElement | <optional> | The node into which the legend content is rendered. |
style.theme | Object | <optional> | The current theme. |
theme.type | string | <optional> | Key for the legend method in the mapp.ui.layers.legends{} library object. |
- Source