Legacy
Mapbox.js is no longer in active development. To learn more about our newer mapping tools see Mapbox GL JS.
L.mapbox.legendControl(options)
Extends: L.Control
A map control that shows legends added to maps in Mapbox. Legends are auto-detected from active layers.
Options | Value | Description |
---|---|---|
options optional | object | An options object. Beyond the default options for map controls, this object has one special parameter: sanitizer : A function that accepts a string, and returns a sanitized result for HTML display. The default will remove dangerous script content, and is recommended. |
Example:
var map = L.mapbox.map('map').setView([38, -77], 5);
map.addControl(L.mapbox.legendControl());
Returns: a L.mapbox.legendControl
object.
Class: L.mapbox.LegendControl
legendControl.addLegend(legend)
Adds a legend to the legendControl.
Options | Value | Description |
---|---|---|
legend required | string | A string which may contain HTML. It will be sanitized by the legendControl's sanitizer option. |
legendControl.removeLegend(legend)
Removes a legend from the legendControl.
Options | Value | Description |
---|---|---|
legend required | string | legend data to remove. |