Reusable Accessible Mapping Platform

API Docs for: 5.0.0
Show:

LayerGroup Class

Imports RAMP Modules:

TmplHelper
Array
LayerItem

Uses RAMP Templates:

templates/layer_selector_template.json

Constructor

LayerGroup

(
  • layers
  • [options]
)
LayerGroup

Parameters:

  • layers Array

    an array of layer config definitions to be added to the group

  • [options] Object optional

    Additional options

    • [groupType] String optional

      Specifies type of this LayerGroup and the name of the layer group template to use

    • [layerState] String optional

      Specifies the initial state of any LyerItem added to this group; must be one of the LayerItem.state defaults

    • [layerType] String optional

      Specifies type of any LayerItem added to this group and the name of the layer item template to use

    • [stateMatrix] Object optional

      additional state matrix records to be mixed into the default

    • [transitionMatrix] Object optional

      additional state transition matrix records to be mixed into the default

Returns:

LayerGroup:

A control object representing a group of layers allowing to dynamically change their states.

Methods

_addStateMatrixPart

(
  • stateMatrix
  • partType
  • partKey
)
private

Modifies the state matrix by adding specified partKey to the specified partType collection

Parameters:

  • stateMatrix Object

    matrix to modify

  • partType String

    type of the parts to modify: controls, toggles, notices

  • partKey String

    part key to be inserted into the collection

_addStateMatrixPart

(
  • stateMatrix
  • partType
  • partKey
)
private

Modifies the state matrix by removing specified partKey to the specified partType collection

Parameters:

  • stateMatrix Object

    matrix to modify

  • partType String

    type of the parts to modify: controls, toggles, notices

  • partKey String

    part key to be removed into the collection

_constructStateMatrix

(
  • layerConfig
)
Object private

Modifies the state matrix of the layer to accommodate types of layers that might not use/have all the default controls or have extra controls.

Parameters:

  • layerConfig Object

    layer config

Returns:

Object:

modified layer state matrix

_template

(
  • key
  • data
)
String private

Populates a template specified by the key with the supplied data.

Parameters:

  • key String

    template name

  • data Object

    data to be inserted into the template

Returns:

String:

a string template filled with supplied data

addLayerItem

(
  • layer
  • options
)
Object

Constructs and adds a LayerItem to the LayerGroup.

Parameters:

  • layer Object

    config of the layer to be added

  • options Object

    additional options allowing for customization

Returns:

Object:

the item that was added

getLayerItem

(
  • layerId
)
LayerItem

Finds and returns a LayerItem object with the specified id. If none found, returns null.

Parameters:

  • layerId String

    an id of the LayerItem to return

Returns:

LayerItem:

a LayerItem with the specified id

removeLayerItem

(
  • layerId
)
Object

Removes the specified LayerItem from the LayerGroup.

Parameters:

  • layerId String

    id of the layer to be removed

Returns:

Object:

this LayerGroup for chaining

setState

(
  • layerId
  • state
  • options
)

Constructs and adds a LayerItem to the LayerGroup.

Parameters:

  • layerId String

    an id of the LayerItem to set the state on

  • state String

    state to be set; must be one of the LayerItem.state defaults

  • options Object

    additional options allowing for customization

Properties

groupType

String

Specifies type of this LayerGroup and the name of the layer group template to use; is set by groupType value;

Default: "layer_group"

layerItems

Array

An array of resulting LayerItem objects.

Default: []

layers

Array

An array of layer config definitions to be added to the group during initialization; is set to layers value.

Default: []

node

JObject

A node of the LayerGroup.

Default: null

node

JObject private

A node of the list in the LayerGroup.

Default: null

state

String

State of any LayerItem added to this group during its initialization; is set by layerSate value; can be overwritten when adding individual layers by options.state.

Default: LayerItem.state.DEFAULT

templates

Object

Templates to be used in construction of the layer nodes.

Default: layer_selector_template.json

type

String

Specifies type of any LayerItem added to this group during initialization and the name of the layer item template to use; is set by layerType value;; can be overwritten when adding individual layers by options.type.

Default: null