new LayerSwitcher(options)
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options | Object |
control options
|
Fires:
- layerswitcher:add
- layerswitcher:remove
- layerswitcher:extent
- layerswitcher:change:opacity
- layerswitcher:change:visibility
- layerswitcher:change:position
Example
map.addControl(new ol.control.LayerSwitcher(
[
{
layer : wms1,
config : {
title : "test layer name 1",
description : "test layer desc 1",
}
}
],
{
collapsed : true,
panel : false,
counter : false,
position : "top-left"
}
));
LayerSwitcher.on("layerswitcher:add", function (e) {
console.warn("layer", e.layer);
});
LayerSwitcher.on("layerswitcher:remove", function (e) {
console.warn("layer", e.layer);
});
LayerSwitcher.on("layerswitcher:change:opacity", function (e) {
console.warn("layer", e.layer, e.opacity);
});
LayerSwitcher.on("layerswitcher:change:visibility", function (e) {
console.warn("layer", e.layer, e.visibility);
});
LayerSwitcher.on("layerswitcher:change:position", function (e) {
console.warn("layer", e.layer, e.position);
});
Extends
- ol.control.Control
Members
-
collapsed
-
{Boolean} true if widget is collapsed, false otherwise
Methods
-
_onZoomToExtentClick(e)
Controls/LayerSwitcher/LayerSwitcher.js, line 1214 -
zoom to extent
Name Type Description e PointerEvent Event
-
_updateLayerCounter()
Controls/LayerSwitcher/LayerSwitcher.js, line 848 -
update layer counter
-
addLayer(layer, config)
Controls/LayerSwitcher/LayerSwitcher.js, line 244 -
Add a new layer to control (when added to map) or add new layer configuration
Name Type Description layer ol.layer.Layer layer to add to layer switcher
config Object optional additional options for layer configuration
Name Type Description title Object optional layer title (default is layer identifier)
description Object optional layer description (default is null)
legends Object optional layer legends (default is an empty array)
metadata Object optional layer metadata (default is an empty array)
quicklookUrl Object optional layer quicklookUrl (default is null)
Fires:
- layerswitcher:add
Example
layerSwitcher.addLayer( gpParcels, { title : "Parcelles cadastrales", description : "description de la couche", quicklookUrl : "http://quicklookUrl.fr" } )
-
getCollapsed(){Boolean}
Controls/LayerSwitcher/LayerSwitcher.js, line 486 -
Returns true if widget is collapsed (minimize), false otherwise
Returns:
collapsed
-
getContainer(){DOMElement}
Controls/LayerSwitcher/LayerSwitcher.js, line 522 -
Get container
-
getLayerDOMId(olLayer){String}
Controls/LayerSwitcher/LayerSwitcher.js, line 1367 -
Returns Layer Container Id associated with given olLayer
Name Type Description olLayer ol.layer.Layer ol layer object
Returns:
container Id ; null if layer not found.
-
getLayerInfo(layer){Object}
Controls/LayerSwitcher/LayerSwitcher.js, line 1413 -
Get layer informations : title, description, quicklookurl, legends, metadata
Name Type Description layer Object the ol.layer object
Returns:
- layer informations
-
isInRange(layer, map){Boolean}
Controls/LayerSwitcher/LayerSwitcher.js, line 1387 -
Check if map view is out of layer range (in terms of extent and zoom)
Name Type Description layer Object the ol.layer object
map Object the ol.Map object
Returns:
- false if map view is out of layer range
-
removeLayer(layer)
Controls/LayerSwitcher/LayerSwitcher.js, line 398 -
Remove a layer from control
Name Type Description layer ol.layer.Layer layer.
- Deprecated
- on the future version ...
Fires:
- layerswitcher:remove
-
setCollapsed(collapsed)
Controls/LayerSwitcher/LayerSwitcher.js, line 462 -
Collapse or display control main container
Name Type Description collapsed Boolean True to collapse control, False to display it
-
setMap(map)
Controls/LayerSwitcher/LayerSwitcher.js, line 144 -
Overload setMap function, that enables to catch map events, such as movend events.
Name Type Description map ol.Map Map.
-
setRemovable(layer, removable)
Controls/LayerSwitcher/LayerSwitcher.js, line 496 -
Display or hide removeLayerPicto from layerSwitcher for this layer
Name Type Description layer ol.layer.Layer ol.layer to be configured
removable Boolean specify if layer can be remove from layerSwitcher (true) or not (false). Default is true