Class: LayerSwitcher

ol.control. LayerSwitcher

OpenLayers 3 Layer Switcher Control.


new LayerSwitcher( [options])

Parameters:
Name Type Argument Description
options Object <optional>
Properties
Name Type Description
displayInLayerSwitcher function

function that takes a layer and return a boolean if the layer is displayed in the switcher, default test the displayInLayerSwitcher layer attribute

show_progress boolean

show a progress bar on tile layers, default false

mouseover boolean

show the panel on mouseover, default false

reordering boolean

allow layer reordering, default true

trash boolean

add a trash button to delete the layer, default false

oninfo function

callback on click on info button, if none no info button is shown DEPRECATED: use on(info) instead

extent boolean

add an extent button to zoom to the extent of the layer

onextent function

callback when click on extent, default fits view to extent

drawDelay number

delay in ms to redraw the layer (usefull to prevent flickering when manipulating the layers)

collapsed boolean

collapse the layerswitcher at beginning, default true

Layers attributes that control the switcher - allwaysOnTop {boolean} true to force layer stay on top of the others while reordering, default false - displayInLayerSwitcher {boolean} display in switcher, default true - noSwitcherDelete {boolean} to prevent layer deletion (w. trash option = true), default false

Fires:
  • event:drawlist
  • event:toggle

Extends

Members


tip

List of tips for internationalization purposes

Methods


_getLayerForLI(li)

Get the layer associated with a li

Parameters:
Name Type Description
li Element
Returns:
Type
ol.layer

_setLayerForLI(li, layer)

Set the layer associated with a li

Parameters:
Name Type Description
li Element
layer ol.layer

displayInLayerSwitcher(layer)

Test if a layer should be displayed in the switcher

Parameters:
Name Type Description
layer ol.layer
Returns:

true if the layer is displayed

Type
boolean

drawList(element)

Render a list of layer

Parameters:
Name Type Description
element Elemen

to render


drawPanel()

Draw the panel control (prevent multiple draw due to layers manipulation on the map with a delay function)


hide()

Hide control


isOpen()

Is control open

Returns:
Type
boolean

overflow(dir)

Calculate overflow and add scrolls

Parameters:
Name Type Description
dir Number

scroll direction -1|0|1|'+50%'|'-50%'


setHeader(html)

Add a custom header

Parameters:
Name Type Description
html Element | string

content html


setMap(map)

Set the map instance the control is associated with.

Parameters:
Name Type Description
map _ol_Map_

The map instance.


show()

Show control


switchLayerVisibility(l, related)

Change layer visibility according to the baselayer option

Parameters:
Name Type Description
l ol.layer
related Array.<ol.layer>

layers


testLayerVisibility(layer)

Check if layer is on the map (depending on zoom and extent)

Parameters:
Name Type Description
layer ol.layer
Returns:
Type
boolean

toggle()

Toggle control