Class LegendControl

L.Class powers the OOP facilities of Leaflet and is used to create almost all of the Leaflet classes documented.

Hierarchy

Index

Constructor methods

Methods

Constructor methods

constructor(options?: ControlOptions): Control

Creates a control with the given options.

Parameters

Returns

Control

Methods

public addLegend(legend: string): any

Adds a legend to the legendControl.

Parameters

  • legend: string

Returns

any

public addTo(map: Map): Control

Adds the control to the map.

Parameters

Returns

Control

public getContainer(): HTMLElement

Returns the HTML container of the control.

Returns

HTMLElement

public getPosition(): string

Returns the current position of the control.

Returns

string

public onAdd(map: Map): any

Parameters

Returns

any

public onRemove(map: Map)

Optional, should contain all clean up code (e.g. removes control's event listeners). Called on map.removeControl(control) or control.removeFrom(map). The control's DOM container is removed automatically.

Parameters

public removeFrom(map: Map): Control

Removes the control from the map.

Parameters

Returns

Control

public removeLegend(legend: string): any

Removes a legend from the legendControl.

Parameters

  • legend: string

Returns

any

public setPosition(position: string): Control

Sets the position of the control. See control positions.

Parameters

  • position: string

Returns

Control