new UI(baseLayers, optionsopt) → {UI}
Base class for VisiOmatic dialog controls.
Parameters
-
baseLayers
Array.<VTileLayer>
Array of layers
-
options
object
<optional>
Options.
Properties
-
title
string
<optional>
'a control related to VisiOmatic'Layer title. Defaults to the basename of the tile URL with extension removed.
-
collapsed
boolean
<optional>
trueStart dialog in the collapsed state?
-
position
boolean
<optional>
'topleft'Position of the dialog on the map.
-
title
See
- Leaflet API reference]https://leafletjs.com/reference.html#control
Returns
-
UI
VisiOmatic UI instance.
Source
Methods
_addButton(className, parent, subClassNameopt, titleopt, fnopt) → {object}
Add a new button to the provided parent element.
Parameters
-
className
string
Class name for the button.
-
parent
object
The parent element.
-
subClassName
string
<optional>
Sub-class name for the button (will be combined with ClassName to generate a unique element id).
-
title
string
<optional>
Title of the button (for, e.g., display as a tooltip).
-
fn
UI~controlCallback
<optional>
Callback function for when the button is pressed.
Returns
-
object
The newly created button.
Source
_addColorPicker(className, parent, subClassName, defaultColor, storageKey, titleopt, fnopt) → {object}
Add a new color picker to the provided parent element.
Parameters
-
className
string
Class name for the color picker.
-
parent
object
The parent element.
-
subClassName
string
Sub-class name for the color picker (will be combined with ClassName to generate a unique element id).
-
defaultColor
string
Default color picked by default.
-
storageKey
string
String to be used as a local browser storage key.
-
title
string
<optional>
Title of the color picker (for, e.g., display as a tooltip).
-
fn
UI~colorCallback
<optional>
Callback function for when a color has been picked.
Returns
-
object
The newly created color picker.
Source
_addDialogBox(idopt) → {object}
Add a new dialog box to the UI.
Parameters
-
id
string
<optional>
DOM id property of the box element.
Returns
-
object
The newly created dialog box.
Source
_addDialogElement(line) → {object}
Add a new dialog element to the provided dialog line.
Parameters
-
line
object
The destination dialog line.
Returns
-
object
The newly created dialog element.
Source
_addDialogLine(label, dialogBox) → {object}
Add a new dialog line to the provided dialog box.
Parameters
-
label
string
Default text in the dialog line.
-
dialogBox
object
The destination dialog box.
Returns
-
object
The newly created dialog line.
Source
_addLayerItem(obj) → {object}
Add control item element for the provided layer parent object.
Parameters
-
obj
object
Layer parent object.
Returns
-
object
The control item element.
Source
_addNumericalInput(layer, attr, box, label, titleopt, initValue, step, minopt, maxopt, fnopt) → {object}
Add a new numerical input widget to the provided box element for updating a layer attribute .
Parameters
-
layer
VTileLayer
Layer affected by the numerical update.
-
attr
string
Name of the (numerical) layer attribute to be updated.
-
box
object
The parent box element.
-
label
string
Text for the created dialog line.
-
title
string
<optional>
Title of the numerical input (for, e.g., display as a tooltip).
-
initValue
number
Initial numerical value.
-
step
number
Starting step value.
-
min
number
<optional>
Minimum value.
-
max
number
<optional>
Maximum value.
-
fn
UI~layerCallback
<optional>
Callback function for when the numerical input has been updated.
Returns
-
object
The newly created numerical input.
Source
_addRadioButton(className, parent, value, checked, titleopt, fnopt) → {object}
Add a new radio button to the provided parent element.
Parameters
-
className
string
Class name for the radio button.
-
parent
object
The parent element.
-
value
*
Value associated with the radio button (e.g., button index or label).
-
checked
boolean
Initial status of the button.
-
title
string
<optional>
Title of the button (for, e.g., display as a tooltip).
-
fn
UI~controlCallback
<optional>
Callback function for when the button is pressed.
Returns
-
object
The newly created radio button.
Source
_addSelectMenu(className, parent, Item, disabledopt, selectedopt, titleopt, fnopt) → {object}
Add a new selection menu to the provided parent element.
Parameters
-
className
string
Class name for the selection menu.
-
parent
object
The parent element.
-
Item
Array.<string>
list.
-
disabled
Array.<boolean>
<optional>
Item-disabling flag list.
-
selected
number
<optional>
Selected item index.
-
title
string
<optional>
Title of the selection menu (for, e.g., display as a tooltip).
-
fn
UI~controlCallback
<optional>
Callback function for when an item is selected.
Returns
-
object
The newly created selection menu.
Source
_addSwitchInput(layer, attr, box, label, titleopt, checked) → {object}
Add a new layer attribute flip switch to the provided box element.
Parameters
-
layer
VTileLayer
Layer affected by the flip switch action.
-
attr
string
Name of the (boolean) layer attribute to be flipped.
-
box
object
The parent box element.
-
label
string
Text for the created dialog line.
-
title
string
<optional>
Title of the flip switch (for, e.g., display as a tooltip).
-
checked
boolean
Initial switch position.
Returns
-
object
The newly created flip switch.
Source
_checkVisiomatic(e)
Check that the layer being loaded is a VisiOmatic layer.
Parameters
-
e
leaflet.LayerEvent
Leaflet layer event object.
Source
_collapse()
Collapse a DOM element (by removing '-expanded' from its class name).
Source
_expand()
Expand a DOM element (by adding '-expanded' to its class name).
Source
_findActiveBaseLayer() → {object}
Find the base VisiOmatic layer currently active on the map.
Returns
-
object
The active VisiOmatic layer, or
undefined
otherwise.
Source
_initDialog()
Initialize the UI dialog (dummy in the base class, just a placeholder).
Source
_onLayerChange(e)
Trigger layer list update when an (overlay) layer is added or removed.
Parameters
-
e
leaflet.LayerEvent
Leaflet layer event object.
Source
_resetDialog()
Reset the UI dialog.
Source
_spinboxStep(min, max) → {number}
Compute a step for the spinbox widget from the provided min and max values.
Parameters
-
min
number
Minimum value.
-
max
number
Maximum value.
Returns
-
number
The computed step value.
Source
_updateInput(element, value)
Update the value stored in a widget element.
Parameters
-
element
object
Widget element.
-
value
*
New value.
Source
_updateLayerList() → {object}
Update the control list of layers.
Returns
-
object
This (control).
Source
addLayer(layer, name, indexopt) → {object}
Add (overlay) layer from the present control.
Parameters
-
layer
leaflet.Layer
Layer to be added.
-
name
string
Layer name.
-
index
number
<optional>
Layer depth index.
Returns
-
object
This (control).
Source
addTo(dest) → {object}
Add the control to the map or to a sidebar.
Parameters
-
dest
object
Destination map or sidebar.
Returns
-
object
Destination object.
Listens to events
- event:layeradd
Source
getActiveBaseLayer() → {object}
Get the base layer currently active on the map.
Returns
-
object
Tile- or overlay layer.
Source
onAdd(map) → {object}
Add the control dialog directly to the map.
Parameters
-
map
object
Leaflet map the control has been added to.
Returns
-
object
The newly created container of the dialog.
Source
removeLayer(layer) → {object}
Remove (overlay) layer from the present control.
Parameters
-
layer
leaflet.Layer
Layer to be removed.
Returns
-
object
This (control).
Source
Type Definitions
colorCallback()
Callbacks for color picker changes.
Source
controlCallback(UI)
Callbacks for UI control changes.
Parameters
-
UI
object
control object.
Source
layerCallback(layer)
Callbacks for layer attribute changes.
Parameters
-
layer
VTileLayer
VisiOmatic layer.