Geoportal Extension for Leaflet API Reference

Namespace: LayerSwitcher


Leaflet Control Class to manage map layers : their order, visibility and opacity, and display their informations (title, description, legends, metadata...)

Use L.geoportalControl.LayerSwitcher() factory to create instances of that class.

Extends Leaflet L.Control.Layers native class.


addLayer(layer, config)

Leaflet/Controls/LayerSwitcher.js, line 798

Adding layer configuration to be displayed by the control

Name Type Description
layer Object

layer to add to layer switcher

config Object

See L.geoportalControl.LayerSwitcher() for layer display config object definition.


Leaflet/Controls/LayerSwitcher.js, line 341

Method 'addTo'
(overwritten : L.Control.Layers because of exception with _expandIfNotCollapsed())

Name Type Description
map Object

the map

setOpacity(layer, opacity)

Leaflet/Controls/LayerSwitcher.js, line 846

Set the opacity of a layer, and opacity must be a number from 0 to 1.

Name Type Description
layer Object

layer into layerswitcher

opacity Number


setVisibility(layer, visibility)

Leaflet/Controls/LayerSwitcher.js, line 873

Set the visibility of a layer.

Name Type Description
layer Object

layer into layerswitcher

visibility Object