new LayerSwitcher( [options])
Parameters:
| Name | Type | Argument | Description |
|---|---|---|---|
options |
Mapspace.control.ControlOptions |
<optional> |
Control options. |
- Source:
- mapspace/controls/layerswitcher.js
Fires:
- Mapspace.control.event:LayerSwitcherEvent
Extends
Methods
-
addGroup(layer, layerIndex, swipeLayerName, groups)
-
Adds a layer group to the control.
Parameters:
Name Type Argument Description layerMapspace.layer.Group A layer group to show in the control.
layerIndexnumber The index of the layer in the viewer.
swipeLayerNamestring <nullable>
Optional param. The name of the swipe layer. If swipe layer is a sublayer of a group swipeLayerName has this pattern: 'group_name#path#sublayer_name'. If null there is no swipe layer.
groupsboolean If there are going to be layer groups in the list or not.
- Source:
- mapspace/controls/layerswitcher.js
-
addLayer(layer, layerIndex, userLayerName, enabled, swipeLayerName, groups)
-
Adds a layer to the control.
Parameters:
Name Type Argument Description layerol.layer.Layer A simple layer to show in the control.
layerIndexnumber The index of the layer in the viewer.
userLayerNamestring Name of the user layer for this layer.
enabledboolean If the layer is currently enabled or not. A layer that is not enabled is not visible even if visible is true, and its name appears greyed out.
swipeLayerNamestring <nullable>
Optional param. The name of the swipe layer. If swipe layer is a sublayer of a group swipeLayerName has this pattern: 'group_name#path#sublayer_name'. If null there is no swipe layer.
groupsboolean If there are going to be layer groups in the list or not.
- Source:
- mapspace/controls/layerswitcher.js
-
addSection(element, name, key, text, classType, collapsed)
-
Adds a section button to the control.
Parameters:
Name Type Argument Description elementHTMLElement Element in which inserting the section.
namestring Name for the section.
keystring <nullable>
Globalization key. If not provided or not exist a value for it the default text will be used.
textstring Default text to show in case globalization key is null or not exist.
classTypeObject Optional class type to use for creation of the element that must be returned.
collapsedboolean <nullable>
Optional boolean. If section must be created collapsed or not.
- Inherited From:
- Source:
- mapspace/controls/toolscontrol.js
Returns:
Element for inserting controls or control if classType param is passed.
- Type
- HTMLElement | Mapspace.control.Control
-
clearControl()
-
Clears all the HTML elements under the control element and clear listeners.
- Source:
- mapspace/controls/layerswitcher.js
-
clearLayers()
-
Removes all layers in the layerToggles list, destroying the input control of type radio and removing event listeners.
- Source:
- mapspace/controls/layerswitcher.js
-
containsInteractiveTool(tool)
-
Returns true if this control contains the given interactive tool.
Parameters:
Name Type Argument Description toolMapspace.InteractiveToolNames <nullable>
The tool name.
- Inherited From:
- Source:
- mapspace/controls/toolscontrol.js
Returns:
- Type
- boolean
-
getButtonDisabled(name)
-
Gets if a button is disabled or not.
Parameters:
Name Type Description nameMapspace.ToolNames The name of the button.
- Inherited From:
- Source:
- mapspace/controls/toolscontrol.js
Returns:
- Type
- boolean
-
getButtonSelected(name)
-
Gets if a button is selected or not.
Parameters:
Name Type Description nameMapspace.ToolNames The name of the button.
- Inherited From:
- Source:
- mapspace/controls/toolscontrol.js
Returns:
- Type
- boolean
-
getButtonVisibility(name)
-
Gets the visibility of a button.
Parameters:
Name Type Description nameMapspace.ToolNames The name of the button.
- Inherited From:
- Source:
- mapspace/controls/toolscontrol.js
Returns:
- Type
- boolean
-
getCurrentInteractiveTool()
-
Returns the current interactive tool selected in the control or null if none.
- Inherited From:
- Source:
- mapspace/controls/toolscontrol.js
Returns:
-
getSectionsUniqueNumber()
-
Returns a unique number (as string) to use in IDs inside sections, to avoid collisions between IDs. Each control deriving this class must implement its own method.
- Inherited From:
- Source:
- mapspace/controls/toolscontrol.js
Returns:
- Type
- string
-
getSelectedItem()
-
Gets an object with: type of item selected, path of current layer group selected, and name of layer inside a layer group selected or legend of style rule.
- Source:
- mapspace/controls/layerswitcher.js
Returns:
- Type
- Object
-
getSelectedLayerIndex()
-
Gets the index of the selected layer.
- Source:
- mapspace/controls/layerswitcher.js
Returns:
The index or -1 if no layer is selected.
- Type
- number
-
getSidePanel()
-
Returns the reference to the Side Panel this panel belongs to or null if no Side Panel is set.
- Inherited From:
- Source:
- mapspace/controls/toolscontrol.js
Returns:
-
getToolObjects()
-
Returns the array of objects that contain the tool buttons.
- Inherited From:
- Overrides:
- Source:
- mapspace/controls/toolscontrol.js
Returns:
- Type
- Array.<Mapspace.ToolDefinition>
-
isInsideExternalControl()
-
Returns true if this control is inside an external control, that is one control that is not associated with a given viewer, like a panel in the
Mapspace.control.SidePanel.- Source:
- mapspace/controls/layerswitcher.js
Returns:
- Type
- boolean
-
isSectionCollapsed(name)
-
Returns true if a section is collapsed.
Parameters:
Name Type Description namestring Name of section.
- Inherited From:
- Source:
- mapspace/controls/toolscontrol.js
Returns:
- Type
- boolean
-
isSectionVisible(name)
-
Returns true if a section is visible.
Parameters:
Name Type Description namestring Name of section.
- Inherited From:
- Source:
- mapspace/controls/toolscontrol.js
Returns:
- Type
- boolean
-
removeLayer(layerIndex)
-
Removes a layer in the control.
Parameters:
Name Type Description layerIndexnumber The index of the layer in the viewer.
- Source:
- mapspace/controls/layerswitcher.js
-
selectInteractiveTool(tool)
-
Sets one interactive tool as selected. If tool passed is null then any interactive tool in the control is unselected. This function do not executes any related action due to tool selection, it just modifies the visual state of buttons.
Parameters:
Name Type Argument Description toolMapspace.InteractiveToolNames <nullable>
The tool name.
- Inherited From:
- Source:
- mapspace/controls/toolscontrol.js
-
selectLayer(layerIndex, layerPath, layerName, ruleIndex)
-
Selects a layer in the control.
Parameters:
Name Type Argument Description layerIndexnumber The index of the layer in the viewer.
layerPathstring <nullable>
Optional path of the layer group in which select.
layerNamestring <nullable>
Optional layer name of the layer to select.
ruleIndexnumber <nullable>
Optional index a style rule (when layer has a style collection).
- Source:
- mapspace/controls/layerswitcher.js
-
setAllButtonsVisibility(viewType)
-
Sets the visibility of buttons to the correct one for the given view type.
Parameters:
Name Type Description viewTypeMapspace.ViewType The view type.
- Inherited From:
- Source:
- mapspace/controls/toolscontrol.js
-
setButtonDisabled(name, disabled)
-
Sets if a button is disabled or not. This do not trigger any event, just modifies the visual state of the button.
Parameters:
Name Type Description nameMapspace.ToolNames The name of the button.
disabledboolean If the button must be disabled or not.
- Inherited From:
- Source:
- mapspace/controls/toolscontrol.js
-
setButtonSelected(name, selected)
-
Sets if a button is selected or not. This do not trigger any event, just modifies the visual state of the button.
Parameters:
Name Type Description nameMapspace.ToolNames The name of the button.
selectedboolean If the button must be selected or not.
- Inherited From:
- Source:
- mapspace/controls/toolscontrol.js
-
setButtonsVisibility(names, visible)
-
Sets the visibility of a button or several buttons using its tools name.
Parameters:
Name Type Description namesMapspace.ToolNames | Array.<Mapspace.ToolNames> One or several names of the buttons to modify.
visibleboolean If the buttons must be visible or not.
- Inherited From:
- Source:
- mapspace/controls/toolscontrol.js
-
setInsideExternalControl(inside)
-
Sets if this control is inside an external control, that is one control that is not associated with a given viewer, like a panel in the
Mapspace.control.SidePanel.Parameters:
Name Type Description insideboolean True if it is inside.
- Source:
- mapspace/controls/layerswitcher.js
-
setSectionCollapsed(name, collapsed)
-
Sets a section as collapsed or uncollapsed.
Parameters:
Name Type Description namestring Name of the section.
collapsedboolean True to collapse, false to uncollapse.
- Inherited From:
- Source:
- mapspace/controls/toolscontrol.js
-
setSectionVisible(name, visible)
-
Sets a section visible or hidden.
Parameters:
Name Type Description namestring Name of the section.
visibleboolean True to show, false to hide.
- Inherited From:
- Source:
- mapspace/controls/toolscontrol.js
-
setSidePanel(panel)
-
Sets the reference to the Side Panel this panel belongs to. This do not re-targets the HTML element of the panel. Use setTarget for that.
Parameters:
Name Type Description panelMapspace.control.SidePanel The Side panel reference.
- Inherited From:
- Source:
- mapspace/controls/toolscontrol.js
-
unselectLayers()
-
Unselects all layers in the control.
- Source:
- mapspace/controls/layerswitcher.js
-
updateControl(element)
-
Updates the control.
Parameters:
Name Type Description elementHTMLElement The element of the control.
- Source:
- mapspace/controls/layerswitcher.js