LayerItem Class
Create a layer item for each map layer to be displayed in the layer selector. Allows for dynamic changing of the layer item state.
Imports RAMP Modules:
TmplHelper
TmplUtil
Array
Dictionary
Uses RAMP Templates:
templates/layer_selector_template.json
Constructor
LayerItem
-
config
-
[options]
Parameters:
-
config
Objecta config definition of the layer
-
[options]
Object optionalAdditional options
-
[state]
String optionalSpecifies the initial state of the LyerItem; must be one of the
LayerItem.state
defaults -
[type]
String optionalSpecifies type of this LayerItem and the name of the layer item template to use
-
[stateMatrix]
Object optionaladditional state matrix records to be mixed into the default
-
[transitionMatrix]
Object optionaladditional state transition matrix records to be mixed into the default
-
Returns:
A control object representing a layer allowing to dynamically change its state.
Item Index
Properties
- _config
- _controlsNode
- _controlStore
- _displayNameNode
- _imageContainerNode
- _noticeStore
- _togglesNode
- _toggleStore
- id
- LayerItem.controls static
- LayerItem.notices static
- LayerItem.state static
- LayerItem.stateMatrix static
- LayerItem.toggles static
- LayerItem.transitionMatrix static
- node
- state
- stateMatrix
- templates
- transitionMatrix
- type
Methods
_generatePart
-
templateKey
-
pKey
-
[data]
Generates a control given the template name and additional data object to pass to the template engine.
Parameters:
Returns:
Created part node
_generateParts
-
partType
-
templateKey
-
partStore
Generates control, toggle, and notice nodes for the LayerItem object to be used in different states.
_setParts
-
partType
-
partStore
-
target
Sets controls, toggles, and notices of the LayerItem according to its state.
_template
-
key
-
data
Populates a template specified by the key with the supplied data.
Returns:
a string template filled with supplied data
setState
-
state
-
[options]
-
force
Changes the state of the LayerItem and update its UI representation.
Parameters:
-
state
Stringname of the state to be set
-
[options]
Object optionaladditional options
-
[notices]
Object optionalcustom information to be displayed in a notice for the current state if needed; object structure is not set; look at the appropriate template;
-
-
force
Booleanif
true
, forces the state change even if it's no allowed by thetransitionMatrix
Example:
{
notices: {
error: {
message: "I'm error"
},
scale: {
message: "All your base are belong to us"
}
}
}
Properties
_config
Object
private
A copy of the layer config supplied during LayerItem creation; is set to config
value.
Default: null
_controlsNode
JObject
private
A node of the layer controls.
Default: null
_displayNameNode
JObject
private
A node of the layer display name.
Default: null
_imageContainerNode
JObject
private
A node of the image container.
Default: null
_togglesNode
JObject
private
A node of the layer toggles.
Default: null
LayerItem.controls
Object
static
A default collection of possible LayerItem controls.
Example:
controls: {
METADATA: "metadata",
SETTINGS: "settings",
LOADING: "loading",
REMOVE: "remove",
RELOAD: "reload",
ERROR: "error"
}
LayerItem.notices
Object
static
A default collection of possible LayerItem notices.
Example:
notices: {
SCALE: "scale"
ERROR: "error",
UPDATE: "update"
}
LayerItem.state
Object
static
A default collection of possible LayerItem states.
Example:
state: {
DEFAULT: "layer-state-default",
LOADING: "layer-state-loading",
LOADED: "layer-state-loaded",
UPDATING: "layer-state-updating",
ERROR: "layer-state-error",
OFF_SCALE: "layer-state-off-scale"
}
LayerItem.stateMatrix
Object
static
A default state matrix specifying what controls are active in which state.
Example:
DEFAULT: {
controls: [
LayerItem.controls.METADATA,
LayerItem.controls.SETTINGS
],
toggles: [
LayerItem.toggles.EYE,
LayerItem.toggles.BOX
],
notices: []
},
LOADING: {
controls: [
LayerItem.controls.LOADING
],
toggles: [],
notices: []
},
LOADED: {
controls: [],
toggles: [],
notices: []
},
DEFAULT: {
controls: [
LayerItem.controls.METADATA,
LayerItem.controls.SETTINGS
],
toggles: [
LayerItem.toggles.EYE,
LayerItem.toggles.BOX
],
notices: [
LayerItem.notices.UPDATE
]
},
ERROR: {
controls: [
LayerItem.controls.RELOAD,
LayerItem.controls.REMOVE
],
toggles: [],
notices: [
LayerItem.notices.ERROR
]
},
OFF_SCALE: {
controls: [
LayerItem.controls.METADATA,
LayerItem.controls.SETTINGS
],
toggles: [
LayerItem.toggles.ZOOM,
LayerItem.toggles.EYE,
LayerItem.toggles.BOX
],
notices: [
LayerItem.notices.SCALE
]
}
LayerItem.toggles
Object
static
A default collection of possible LayerItem toggles.
Example:
toggles: {
EYE: "eye",
BOX: "box",
RELOAD: "reload",
HIDE: "hide",
ZOOM: "zoom",
PLACEHOLDER: "placeholder"
}
LayerItem.transitionMatrix
Object
static
A default state transition matrix specifying to what state the LayerItem can transition.
Example:
DEFAULT: [
LayerItem.state.ERROR,
LayerItem.state.OFF_SCALE,
LayerItem.state.UPDATING
],
LOADED: [
LayerItem.state.DEFAULT
],
LOADING: [
LayerItem.state.LOADED
],
UPDATING: [
LayerItem.state.ERROR,
LayerItem.state.OFF_SCALE,
LayerItem.state.DEFAULT
],
ERROR: [
LayerItem.state.LOADING
],
OFF_SCALE: [
LayerItem.state.ERROR,
LayerItem.state.DEFAULT,
LayerItem.state.UPDATING
]
node
JObject
A node of the LayerItem.
Default: null
state
String
State of this LayerItem; can be overwritten by options.state
.
Default: LayerItem.state.DEFAULT
stateMatrix
Object
Specifies a state matrix for this particular LayerItem. The default is mixed with options.stateMatrix
upon initialization.
The state matrix prescribes what controls, toggles, and notices are present in specific states.
Default: LayerItem.stateMatrix
templates
Object
Templates to be used in construction of the layer nodes.
Default: layer_selector_template.json
transitionMatrix
Object
Specifies a state transition matrix for this particular LayerItem. The default is mixed with options.transitionMatrix
upon initialization.
The state transition matrix prescribes the direction of state changes for specific states.
Default: LayerItem.transitionMatrix
type
String
Specifies type of this LayerItem and the name of the layer item template to use; can be overwritten by options.type
.
Default: null