DiscreteLegend
Extends:
Displays a discrete palette legend for the parameter displayed by the given Coverage layer. Supports category parameters only at the moment.
Example:
new C.DiscreteLegend(covLayer).addTo(map)
// changing the palette of the layer automatically updates the legend
covLayer.palette = C.discretePalette(['red', 'blue'])
var fakeLayer = {
parameter: {
observedProperty: {
label: { en: 'Land cover' },
categories: [{
label: { en: 'Land' }
}, {
label: { en: 'Water' }
}]
}
},
palette: C.directPalette(['gray', 'blue']) // CSS colors in category order
}
var legend = new C.DiscreteLegend(fakeLayer).addTo(map)
// change the palette and trigger a manual update
fakeLayer.palette = C.discretePalette(['red', 'blue'])
legend.update()
Constructor Summary
Public Constructor | ||
public |
constructor(covLayer: object, options: object) Creates a discrete legend control. |
Method Summary
Public Methods | ||
public |
update() Triggers a manual update of the legend. |
Public Constructors
public constructor(covLayer: object, options: object) source
Creates a discrete legend control.
Params:
Name | Type | Attribute | Description |
covLayer | object | The coverage data layer, or any object with |
|
options | object |
|
Legend options. |
options.position | string |
|
The initial position of the control (see Leaflet docs). |
options.language | string |
|
A language tag, indicating the preferred language to use for labels. |
options.templateId | string |
|
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.