ALKMaps.Control.LayerSwitcher

The LayerSwitcher control displays a table of contents for the map.  This allows the user interface to switch between BaseLayers and to show or hide Overlays.  By default the switcher is shown minimized on the right edge of the map, the user may expand it by clicking on the handle.

To create the LayerSwitcher outside of the map, pass the Id of a html div as the first argument to the constructor.

Inherits from

Summary
ALKMaps.Control.LayerSwitcherThe LayerSwitcher control displays a table of contents for the map.
Properties
layerStates{Array(Object)} Basically a copy of the “state” of the map’s layers the last time the control was drawn.
layersDiv{DOMElement}
baseLayersDiv{DOMElement}
baseLayers{Array(Object)}
dataLbl{DOMElement}
dataLayersDiv{DOMElement}
dataLayers{Array(Object)}
minimizeDiv{DOMElement}
maximizeDiv{DOMElement}
ascending{Boolean}
Constructor
ALKMaps.Control.LayerSwitcher
Functions
destroy
setMap
draw{DOMElement} A reference to the DIV DOMElement containing the switcher tabs.
onButtonClick
clearLayersArrayUser specifies either “base” or “data”.
checkRedrawChecks if the layer state has changed since the last redraw() call.
redrawGoes through and takes the current state of the Map and rebuilds the control to display that state.
updateMapCycles through the loaded data and base layer input arrays and makes the necessary calls to the Map object such that that the map’s visual state corresponds to what the user has selected in the control.
maximizeControlSet up the labels and divs for the control
minimizeControlHide all the contents of the control, shrink the size, add the maximize icon
showControlsHide/Show all LayerSwitcher controls depending on whether we are minimized or not
loadContentsSet up the labels and divs for the control

Properties

layerStates

{Array(Object)} Basically a copy of the “state” of the map’s layers the last time the control was drawn.  We have this in order to avoid unnecessarily redrawing the control.

layersDiv

{DOMElement}

baseLayersDiv

{DOMElement}

baseLayers

{Array(Object)}

dataLbl

{DOMElement}

dataLayersDiv

{DOMElement}

dataLayers

{Array(Object)}

minimizeDiv

{DOMElement}

maximizeDiv

{DOMElement}

ascending

{Boolean}

Constructor

ALKMaps.Control.LayerSwitcher

Parameters

options{Object}

Functions

destroy

destroy: function()

setMap

setMap: function(map)

Properties

map{ALKMaps.Map}

draw

draw: function()

Returns

{DOMElement} A reference to the DIV DOMElement containing the switcher tabs.

onButtonClick

onButtonClick: function(evt)

Parameters

evt{Event}

clearLayersArray

clearLayersArray: function(layersType)

User specifies either “base” or “data”. we then clear all the corresponding listeners, the div, and reinitialize a new array.

Parameters

layersType{String}

checkRedraw

checkRedraw: function()

Checks if the layer state has changed since the last redraw() call.

Returns

{Boolean} The layer state changed since the last redraw() call.

redraw

redraw: function()

Goes through and takes the current state of the Map and rebuilds the control to display that state.  Groups base layers into a radio-button group and lists each data layer with a checkbox.

Returns

{DOMElement} A reference to the DIV DOMElement containing the control

updateMap

updateMap: function()

Cycles through the loaded data and base layer input arrays and makes the necessary calls to the Map object such that that the map’s visual state corresponds to what the user has selected in the control.

maximizeControl

maximizeControl: function(e)

Set up the labels and divs for the control

Parameters

e{Event}

minimizeControl

minimizeControl: function(e)

Hide all the contents of the control, shrink the size, add the maximize icon

Parameters

e{Event}

showControls

showControls: function(minimize)

Hide/Show all LayerSwitcher controls depending on whether we are minimized or not

Parameters

minimize{Boolean}

loadContents

loadContents: function()

Set up the labels and divs for the control

destroy: function()
setMap: function(map)
draw: function()
{DOMElement} A reference to the DIV DOMElement containing the switcher tabs.
onButtonClick: function(evt)
clearLayersArray: function(layersType)
User specifies either “base” or “data”.
checkRedraw: function()
Checks if the layer state has changed since the last redraw() call.
redraw: function()
Goes through and takes the current state of the Map and rebuilds the control to display that state.
updateMap: function()
Cycles through the loaded data and base layer input arrays and makes the necessary calls to the Map object such that that the map’s visual state corresponds to what the user has selected in the control.
maximizeControl: function(e)
Set up the labels and divs for the control
minimizeControl: function(e)
Hide all the contents of the control, shrink the size, add the maximize icon
showControls: function(minimize)
Hide/Show all LayerSwitcher controls depending on whether we are minimized or not
loadContents: function()
Set up the labels and divs for the control
Controls affect the display or behavior of the map.
Instances of ALKMaps.Map are interactive maps embedded in a web page.
Close