Legend¶
Shows symbology for the layers that are currently visible: single swatches, category lists and gradient bars, each shaped for its geometry (dot, line or square).
- id:
legend - Surfaces:
side-panel
Place it¶
Behavior¶
- Only visible layers with kit symbology or a
legendappear. Raster layers and Esri layers using the service's own styling have nothing for the legend to read, so they're skipped unless they setlegend. - Layers with
simplesymbology get one swatch, shaped bygeometryTypeand drawn at the symbology'sopacityandstrokeOpacity. A layer withoutgeometryType(mixed geometry) gets a small dot, line and square side by side in its color. - Categorized and graduated layers (
rawsymbology withmatchorinterpolateexpressions) become a category list or a gradient bar. - A layer's
symbology.descriptionappears as a muted line under its name, e.g. "Annual passengers". - Order: layers with
rawsymbology or their ownlegendfirst, then points, lines and polygons, keeping your layer order within each. - A PMTiles layer that draws several source layers gets its own block after the other layers: the layer's name as a header, with its visible source layers indented below in draw order. Hidden source layers drop out, and the block disappears when none are visible.
Controlling what shows¶
- Set
legendon any layer or PMTiles source layer to choose its swatches (categories or a gradient), or to bring a raster or service-styled Esri layer into the legend. It wins over arawsymbology'slegend. - Hide a layer from the legend, but keep it on the map, with
"hideFromLegend": true. It works with any symbology.
The legend has no settings block of its own. Everything comes from your layers' symbology and legend fields.