Legend Control

A legend control is responsible for managing the collection of legends currently visible within the context of an interface or map and provides the interface needed for adding and removing legends.

// Adds a legend control to the map, returning the control instance
const control = controller.addLegendControl(options);
// Removes the legend control


The following configuration options are supported when instantiating LegendControl instances:

widthType: number ()Width of the legend control.400
insetsType: number or Array<number> ()Internal padding between the canvas edges and the legend content. If a single value is provided, then that inset is applied for all four sides. If an array of two numbers is provided, then the values indicate the horizontal and vertical insets respectively.4
metricType: boolean ()Whether the default units for legends should be in Metric values.false
toggleOnClickType: boolean ()Whether units should be toggled when clicking on the control.true


The following properties are available on LegendControl instances:

containerType: HTMLElement (readonly)The DOM container for the control.
metricType: boolean ()Whether units are currently in Metric.


The following methods are available on LegendControl instances:


The following events are triggered by LegendControl instances.