Mapbox.js is no longer in active development. To learn more about our newer mapping tools see Mapbox GL JS.

You are viewing an older version of Mapbox.js. Check out v3.3.1 for the latest.


The base class for all Leaflet controls. Implements IControl interface. You can add controls to the map like this:

// the same as


Factory Description
L.control( <Control options> options? ) Creates a control with the given options.


Option Type Default Description
position String 'topright' The initial position of the control (one of the map corners). See control positions.


Method Returns Description
setPosition( <String> position ) this Sets the position of the control. See control positions.
getPosition() String Returns the current position of the control.
addTo( <Map> map ) this Adds the control to the map.
removeFrom( <Map> map ) this Removes the control from the map.
getContainer() HTMLElement Returns the HTML container of the control.

Control Positions

Control positions (map corner to put a control to) are set using strings. Margins between controls and the map border are set with CSS, so that you can easily override them.

Position Description
'topleft' Top left of the map.
'topright' Top right of the map.
'bottomleft' Bottom left of the map.
'bottomright' Bottom right of the map.