L.Control is a base class for implementing map controls. Handles positioning. All other controls extend from this class.


Option Type Default Description
position String 'topright' The position of the control (one of the map corners). Possible values are 'topleft', 'topright', 'bottomleft' or 'bottomright'


Classes extending L.Control will inherit the following methods:
Method Returns Description
getPosition() string

Returns the position of the control.

setPosition(<string> position) this

Sets the position of the control.

getContainer() HTMLElement

Returns the HTMLElement that contains the control.

addTo(<Map> map) this

Adds the control to the given map.

remove() this

Removes the control from the map it is currently active on.

Extension methods

Every control should extend from L.Control and (re-)implement the following methods.
Method Returns Description
onAdd(<Map> map) HTMLElement

Should return the container DOM element for the control and add listeners on relevant map events. Called on control.addTo(map).

onRemove(<Map> map)

Optional method. Should contain all clean up code that removes the listeners previously added in onAdd. Called on control.remove().