Home Reference Source Repository
import {ContinuousLegend} from 'leaflet-coverage/'
public class | source



L.Control → ContinuousLegend

Displays a continuous legend for the parameter displayed by the given coverage data layer.

Note that this class should only be used if the palette is continuous by nature, typically having at least 100-200 color steps. If there are only a few color steps (e.g. 10), then this class will still show a continuous legend due to its rendering technique (CSS gradient based).


Coverage data layer
new C.ContinuousLegend(covLayer).addTo(map)
// changing the palette of the layer automatically updates the legend 
covLayer.palette = C.linearPalette(['blue', 'red'])
Fake layer
var fakeLayer = {
  parameter: {
    observedProperty: {
      label: { en: 'Temperature' }
    unit: {
      symbol: { value: 'K' },
      label: { en: 'Kelvin' }
  palette: linearPalette(['#FFFFFF', '#000000']),
  paletteExtent: [0, 10]
var legend = new C.ContinuousLegend(fakeLayer).addTo(map)

// change the palette and trigger a manual update
fakeLayer.palette = C.linearPalette(['blue', 'red'])

Constructor Summary

Public Constructor

constructor(covLayer: object, options: object)

Creates a continuous legend control.

Method Summary

Public Methods


Triggers a manual update of the legend.

Public Constructors

public constructor(covLayer: object, options: object) source

Creates a continuous legend control.


covLayer object

The coverage data layer, or any object with palette, paletteExtent, and parameter properties. If the object has on/off methods, then the legend will listen for "paletteChange" and "paletteExtentChange" events and update itself automatically. If the layer fires a "remove" event, then the legend will remove itself from the map.

options object
  • optional

Legend options.

options.position string
  • optional
  • default: 'bottomright'

The initial position of the control (see Leaflet docs).

options.language string
  • optional

A language tag, indicating the preferred language to use for labels.

options.templateId string
  • optional

Uses the HTML element with the given id as template.

Public Methods

public update() source

Triggers a manual update of the legend.

Useful if the supplied coverage data layer is not a real layer and won't fire the necessary events for automatic updates.