Map features
Legend
Three layers, three ways to end up with a legend entry — and one panel that only lists what is actually visible right now.
Try it: switch layers off and on — entries appear and disappear with them. A layer outside its zoom range drops out of the legend too, because it is not on the map.
Three sources, one panel
- From the service:
legend: "auto"on a WMS layer builds a GetLegendGraphic request - From the style: vector layers with literal colours produce swatches automatically
- By hand: an array of entries with label, colour and shape (square, line, circle)
legend: false keeps a layer out of the panel entirely, and a plain string is
read as the URL of a legend image — useful when a service draws a bad legend and you host
a better one.
Why not always derive it?
A data-driven style — colour by attribute, width by zoom — has no single swatch that
honestly represents it. map0 only derives a swatch from literal colours and stays quiet
otherwise, rather than showing something misleading.