Controls
Legend

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
controller.removeLegendControl();

Configuration

The following configuration options are supported when instantiating LegendControl instances:

OptionDescriptionDefault
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

Properties

The following properties are available on LegendControl instances:

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

Methods

The following methods are available on LegendControl instances:

Events

The following events are triggered by LegendControl instances.