Reusable Accessible Mapping Platform

API Docs for: 5.0.0
Show:

LayerLoader Class

Layer Loader class.

Handles the asynchronous loading of map layers (excluding basemaps) This includes dealing with errors, and raising appropriate events when the layer loads

Item Index

Methods

_generatePart

(
  • templateKey
  • pKey
  • [data]
)
private

Generates a control given the template name and additional data object to pass to the template engine.

Parameters:

  • templateKey String

    a template name prefix for the template parts

  • pKey String

    name of the template to build

  • [data] Object optional

    optional data to pass to template engine; used to update strings on notice objects

Returns:

Created part node

_generateParts

(
  • partType
  • templateKey
  • partStore
)
private

Generates control, toggle, and notice nodes for the LayerItem object to be used in different states.

Parameters:

  • partType String

    name of the part type - "controls", "toggles", or "notices"

  • templateKey String

    a template name prefix for the template parts

  • partStore Object

    a dictionary to store generated nodes

_getFeatures

(
  • fl
)
Object

Queries all map points on a given feature layer and returns their attributes

Parameters:

  • fl Object

    A feature layer to query

Returns:

Object:

An array of attributes from the designated feature layer

_getField

(
  • fl
  • field
)
Object

Grabs all distinct values of the given field from a featureLayer.

Parameters:

  • fl Object

    A feature layer to query

  • field String

    The field (or column) to query in the feature layer

Returns:

Object:

deferred A deferred object which will resolve to an array of unique values

_hideLoadingImg

() private

Hides the loading image.

_initEventHandlers

(
  • map
)
private

Creates event handlers for the map control: click, mouse-over, load, extent change, and update events.

Parameters:

  • map Object

    A ESRI map object

_initListeners

(
  • map
)
private

Subscribe to external events (published using topic.publish) and react accordingly

Parameters:

_initRepublishers

(
  • map
)
private

Republishes map events to the outside using topic.publish

Parameters:

_initScale

(
  • event
)
private

Initialize Map Scale

Parameters:

_loadLayer

(
  • layer
  • reloadIndex
)
private

This function initiates the loading of an ESRI layer object to the map. Will add it to the map in the appropriate spot, wire up event handlers, and generate any bounding box layers Note: a point of confusion. The layer objects "load" event may have already finished by the time this function is called. This means the object's constructor has initialized itself with the layers data source. This functions is not event triggered to guarantee the order in which things are added.

Parameters:

  • layer Object

    an instantiated, unloaded ESRI layer object

  • reloadIndex Integer

    Optional. If reloading a layer, supply the index it should reside at. Do not set for new layers

_setParts

(
  • partType
  • partStore
  • target
)
private

Sets controls, toggles, and notices of the LayerItem according to its state.

Parameters:

  • partType String

    name of the part type - "controls", "toggles", or "notices"

  • partStore Object

    a dictionary to store generated nodes

  • target JObject

    a jQuery node where the nodes should be appended

_showLoadingImg

() private

Shows the loading image.

_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

_updateScale

(
  • event
)
private

Update Map Scale when zoom level changes

Parameters:

_wrapFileCallInPromise

(
  • readMethod
)
Function private

Helper function for wrapping File API calls in Promise objects. Used for building a series of helpers which call different file read methods.

Parameters:

  • readMethod String

    a string indicating the FileReader method to call

Returns:

Function:

a function which accepts a {File} object and returns a Promise

addLayer

(
  • layerType
  • layerConfig
  • initState
)

Add a provided layer to the layer selector.

Parameters:

  • layerType String

    layer type - name of the layer group

  • layerConfig Object

    a layer config

  • initState String

    optional. the state to initialize in. Default value is LOADING

AddStaticLayer

(
  • layer_type
  • layer_url
  • layer_op
)
private

Add a static, non-interactive Layer to the map

Parameters:

  • layer_type String

    A value which controls how the layer is going to be added to the map

  • layer_url String

    A URL pointing to a valid map service endpoint

  • layer_op Number

    A value between 0.0 and 1.0 which determines the transparency of the layer

adjustPaneWidth

() private

Changes the width of the layers pane to accommodate for the scrollbar if it's needed.

applyExtentDefaulting

() private

Apply extent defaulting prior to URL overrides.

checkBoundary

(
  • e
  • maxExtent
)
Esri/geometry/Extent

Given an ESRI Extent Object, returns a new ESRI Extent Object that contains the extent adjusted according to this map's maximum extent

NOTE: this method is currently unused!

Parameters:

  • e Esri/geometry/Extent

    the extent Object

  • maxExtent Esri/geometry/Extent

    the maximum extent

Returns:

Esri/geometry/Extent:

An adjusted extent, if the target extent is outside the boundary

createGroups

() private

Sets UI status of a layer presentation (checkbox and eye) according to the user action: select / de-select a layer. publishes event "filterManager/box-visibility-toggled" every time a layer status changed. There should only be one eye and one global checkbox, but we say checkbox"es" because jquery returns a list and it's easier to write a function that takes a list of checkboxes than to write two functions, one to take a list and one to take an individual checkbox

enhanceLayer

(
  • layer
  • config
  • userLayer
)

Adds custom ramp properties to layer. Adds handlers to loading events.

Parameters:

  • layer Object

    layer to be prepped

  • config Object

    config object for the layer

  • userLayer Boolean

    optional. indicates if layer was added by a user. default value is false

finishExtentProjection

(
  • projectedMaxExtent
)
private

process the projected maximum extent, then alert app to continue loading the map. used as an asynchronous gate for the projection.

Parameters:

  • projectedMaxExtent Array

    an array containing the maximum extent object in the map's projection

getBoundingBoxMapping

() Object

Returns the mapping of feature layer ids to assocciated bounding box layers.

Returns:

Object:

A dictionary of String, Esri/layers/GraphicsLayer pairs.

getFeatureLayer

(
  • featureId
)
Esri/layers/FeatureLayer private

Return the feature layer corresponding to the given id.

Parameters:

  • featureId String

    the id of the feature layer

Returns:

Esri/layers/FeatureLayer:

feature layer

getLayerItem

(
  • layerId
)
private

Returns a LayerItem object with specified layerId.

Parameters:

getLayerState

(
  • layerId
)
private

Returns the state of the layer with the specified layer id.

Parameters:

getVisibleFeatureLayers

() Array

Returns a list of feature layers that are currently visible on the map.

Returns:

Array:

an array of Esri/layers/FeatureLayer objects

init

()

Initializes properties. Set up event listeners

initListeners

() private

Initiates a listener to handle tab deselected event

initScrollListeners

() private

Adjusts filter style according to the scroll action on the layers.

initTooltips

() private

initialize a tooltip for each layer, using the layer name.

loadLayer

(
  • layer
  • reloadIndex
)

Public endpoint to initiate the loading of an ESRI layer object to the map.

Parameters:

  • layer Object

    an instantiated, unloaded ESRI layer object

  • reloadIndex Integer

    Optional. If reloading a layer, supply the index it should reside at. Do not set for new layers

localProjectExtent

(
  • extent
  • sr
)
Esri/Extent private

Inherited from Map but overwritten in src\js\RAMP\Modules\map.js:420

Will project an extent to a desired spatial reference, using client side projection library. Avoids the need for Esri Geometry Service

Parameters:

Returns:

Esri/Extent:

extent in the desired projection

makeFeatureLayer

(
  • layerConfig
  • userLayer
)
Esri/layers/FeatureLayer

Create a new FeatureLayer object based on the config input

Parameters:

  • layerConfig Object

    config object for the layer to create

  • userLayer Boolean

    optional specifies if layer was added by a user

Returns:

Esri/layers/FeatureLayer:

feature layer object (unloaded)

makeStaticLayer

(
  • layerConfig
  • userLayer
)
Object private

Return the static layer corresponding to the given url.

Parameters:

  • layerConfig Object

    config object for the layer to create

  • userLayer Boolean

    optional specifies if layer was added by a user

Returns:

Object:

layer object of the appropriate type

makeWmsLayer

(
  • layerConfig
  • userLayer
)
Esri/layers/WMSLayer

Return the feature layer corresponding to the given url.

Parameters:

  • layerConfig Object

    config object for the layer to create

  • userLayer Boolean

    optional specifies if layer was added by a user

Returns:

Esri/layers/WMSLayer:

WMS layer

onFeatureDeselect

()

This function is called whenever the "Details" button is deselected (either by the user click on another "Details" button, clicking on another point, or by clicking on an already highlighted "Details" button, or clicking somewhere on the map where is no features present).

onFeatureMouseOut

(
  • evt
)

This function is called whenever the user moves the mouse away from a feature being hovered over.

Parameters:

  • evt Object

    [description]

    • graphic Object

      ESRI graphic object that is moved away from

onFeatureMouseOver

(
  • evt
)

This function is called whenever the user hovers over a feature on the map when another feature already has been selected.

Parameters:

  • evt Object

    [description]

    • graphic Object

      ESRI graphic object that is being hovered over

onFeatureSelect

(
  • evt
)

This function is called whenever the feature on the map is clicked/selected by the user. Publish the "Gui/subPanelOpen" message to indicate a feature has been selected. Panel content and Panel event handler information is passed in as the additional object for the event handler.

Parameters:

onLayerError

(
  • layerId
)
private

Will remove a layer from the map, and adjust counts.

Parameters:

  • layerId String

    config id of the layer

onLayerError

(
  • layerId
  • newState
  • abortIfError
)
private

Will set a layerId's layer selector state to a new state.

Parameters:

  • layerId String

    config id of the layer

  • newState String

    the state to set the layer to in the layer selector

  • abortIfError Boolean

    if true, don't update state if current state is an error state

onLayerError

(
  • evt
)

Deals with a layer that had an error when it tried to load.

Parameters:

onLayerLoaded

(
  • evt
)

Reacts when a layer has loaded successfully. This means the site has shaken hands with the layer and it seems ok. This does not mean data has been downloaded

Parameters:

onLayerRemove

(
  • evt
)

Reacts to a request for a layer to be reloaded. Usually the case when a layer errors and user wants to try again

Parameters:

onLayerRemove

(
  • evt
)

Reacts to a request for a layer to be removed. Usually the case when a layer errors and the user clicks remove.

Parameters:

onLayerUpdateEnd

(
  • evt
)

Reacts when a layer has updated successfully. This means the layer has pulled its data and displayed it.

Parameters:

onLayerUpdateStart

(
  • evt
)

Reacts when a layer begins to update. This happens when a feature layer starts to download its data. Data download doesn't start until points are made visible. It also happens when a WMS requests a new picture.

Parameters:

prepLayer

(
  • layer
  • config
  • userLayer
)
private

Sets up loading event handlers and initializes the .ramp object of a layer Circular reference errors prevent us from calling LayerLoader directly from this module

Parameters:

  • layer Object

    layer to be prepped

  • config Object

    config object for the layer

  • userLayer Boolean

    optional. indicates if layer was added by a user. default value is false

projectConfigExtents

()

initiate the projection of the config extents to basemap extents

projectExtent

(
  • extent
  • sr
  • callWhenDone
)
private

project an extent to a new spatial reference, if required when projection is finished, call another function and pass the result to it.

Parameters:

projectFullExtent

(
  • projectedDefaultExtent
)
private

process the projected default extent, begin projection of full extent. used as an asynchronous gate for the projection.

Parameters:

  • projectedDefaultExtent Array

    an array containing the default extent object in the map's projection

projectMaxExtent

(
  • projectedFullExtent
)
private

process the projected full extent, begin projection of maximum extent. used as an asynchronous gate for the projection.

Parameters:

  • projectedFullExtent Array

    an array containing the full extent object in the map's projection

registerWMSClick

(
  • map
)

This function should be called after the map has been created. It will subscribe to the Map.CLICK event and trigger GUI.SUBPANEL_OPEN events for displaying the response data.

Parameters:

  • map Object

    an EsriMap instance

removeLayer

(
  • layerType
  • layerId
)

Remove a layer from the layer selector.

Parameters:

  • layerType String

    layer type - name of the layer group

  • layerId String

    layer id of layer to remove

republish

(
  • name
)
private

Republish map events using topic.publish

Parameters:

setBoundingBoxVisibility

(
  • layerId
)
private

Sets the visibility of the bounding box that belongs to the layer with the given layerId. Note: the layerId needs to be the ID of the featurelayer, not the ID of the actual bounding box layer.

Parameters:

  • layerId String

    the id of the layer whose bounding box visibility should be set

setButtonEvents

() private

Sets event handlers for various controls that may be present in the layer items. All event handlers are set on the main list container and are independed of the individual layer items.

setLayerOffScaleState

(
  • layerId
)
private

Checks if a specific layer has data that is not visible and sets the appropriate layer state.

Parameters:

setLayerOffScaleStates

() private

Checks if any of the layers have data that is not visible and sets the appropriate layer state.

setLayerReorderingEvents

() private

Sets all the events to handle layer reordering with both mouse and keyboard.

setLayerState

(
  • layerId
  • layerState
  • [options]
)
private

Set the state of the specified layer to the provided value.

Parameters:

  • layerId String

    a layer id

  • layerState String

    a state to set the specified layer to

  • [options] Object optional

    additional options to be passed to the layerItem upon setting state

setState

(
  • state
  • [options]
  • force
)

Changes the state of the LayerItem and update its UI representation.

Parameters:

  • state String

    name of the state to be set

  • [options] Object optional

    additional options

    • [notices] Object optional

      custom information to be displayed in a notice for the current state if needed; object structure is not set; look at the appropriate template;

  • force Boolean

    if true, forces the state change even if it's no allowed by the transitionMatrix

Example:

 {
     notices: {
         error: {
             message: "I'm error"
         },
         scale: {
             message: "All your base are belong to us"
         }
     }
 }

ui.addLayerGroup

() private

Add the provided layer group node to the layer selector ui.

ui.update

() private

Updates certain UI aspects like layer settings panel (visibility sliders for now only), layer visibility and bounding box toggles, and layer sorting.

zoomToLayerScale

(
  • layerId
)

For a specified layer, zooms to the closest level that has some visible data.

Parameters:

  • layerId String

    a layer id to zoom to.

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

_controlStore

Object private

A dictionary of control nodes available for this layer.

Default: {}

_displayNameNode

JObject private

A node of the layer display name.

Default: null

_imageContainerNode

JObject private

A node of the image container.

Default: null

_noticeStore

Object private

A dictionary of notice nodes available for this layer.

Default: {}

_togglesNode

JObject private

A node of the layer toggles.

Default: null

_toggleStore

Object private

A dictionary of toggle nodes available for this layer.

Default: {}

baseLayer

Esri/layers/ArcGISTiledMapServiceLayer private

The basemap layer

boundingBoxMapping

Object private

Maps the id of a graphic layer to the GraphicsLayer Object that represents its extent bounding box. A dictionary of String, Esri/layers/GraphicsLayer pairs.

featureLayers

Array private

An Array of Esri/layers/FeatureLayer objects.

featureLayerStartIndex

Integer private

The map not only contains feature layers, but also other layers such as the basemap layer, highlight layer, bounding box layer, etc. This variable is used to store the starting index of the feature layers in the map.

fullExtent

Esri/geometry/Extent private

Used for full extent in nav widget

getMap

Object

Return the map control object

getMaxExtent

Object

The maximum extent of the map control is allowed to go to

id

String

Layer id. Upon initialization, id can be overwritten by config.id value.

Default: null

InitExtent

Esri/geometry/Extent private

The initial extent of the map

maxExtent

Esri/geometry/Extent private

The maximum extent of the map

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

url

String private

The URL of the first layer of the basemap that is on by default.

wmsLayers

Array private

An Array of Esri/layer/WMSLayer objects.

Events

FilterManager.BOX_VISIBILITY_TOGGLED

Published whenever the "box" button for a layer is clicked

Event Payload:

  • event Object
    • checked Boolean

      true if the "box" button is checked, false otherwise

    • node Object

      the input dom node that represents the checkbox

FilterManager.LAYER_TRANSPARENCY_CHANGED

Published each time the transparency of a layer is modified.

Event Payload:

  • event Object
    • layerId String

      the id of the layer

    • value Int

      the value of the slider

FilterManager.LAYER_VISIBILITY_TOGGLED

Published whenever the "eye" button for a layer is clicked

Event Payload:

  • event Object
    • checked Boolean

      true if the "eye" button is checked, false otherwise

    • node Object

      the input dom node that represents the checkbox

FilterManager.SELECTION_CHANGED

Published whenever the layer list is rearranged

Event Payload:

  • event Object
    • id String

      the layer Id

    • index Integer

      index of the layer that moved. index is relative to the control, not the layer stack in the map

FilterManager.TOGGLE_BOX_VISIBILITY [subscribed]

Tells the filter manager to toggle a layer on or off

Event Payload:

  • event Object
    • layerId String

      the name of the layer to toggle

    • state Boolean

      true if the layer should be visible, false otherwise

FilterManager.TOGGLE_LAYER_VISIBILITY [subscribed]

Tells the filter manager to toggle a layer on or off

Event Payload:

  • event Object
    • layerId String

      the name of the layer to toggle

    • state Boolean

      true if the layer should be visible, false otherwise

FilterManager.UI_COMPLETE

Published after the ui for the filter manager finishes initializing.

LayerLoader.LAYER_ERROR

Provided by the UI module.

Defined in src\js\RAMP\Modules\eventManager.js:445

Indicates that a map layer has errored

Event Payload:

  • event Object
    • layer Object

      ESRI layer object that has errored

    • error Object

      the error object

LayerLoader.LAYER_LOADED

Provided by the UI module.

Defined in src\js\RAMP\Modules\eventManager.js:390

Indicates that a map layer has loaded. This means the constructor initialized and shook hands with it's data source

Event Payload:

  • event Object
    • layer Object

      ESRI layer object that has loaded

LayerLoader.LAYER_UPDATED

Provided by the UI module.

Defined in src\js\RAMP\Modules\eventManager.js:401

Indicates that a map layer has updated. This means the data it is showing is visible and up-to-date

Event Payload:

  • event Object
    • layer Object

      ESRI layer object that has updated

LayerLoader.LAYER_UPDATING

Provided by the UI module.

Defined in src\js\RAMP\Modules\eventManager.js:412

Indicates that a map layer has started updating. This means it is getting data from its source

Event Payload:

  • event Object
    • layer Object

      ESRI layer object that is updating

LayerLoader.RELOAD_LAYER

Provided by the UI module.

Defined in src\js\RAMP\Modules\eventManager.js:434

Indicates that a map layer should be removed from the map

Event Payload:

LayerLoader.REMOVE_LAYER

Provided by the UI module.

Defined in src\js\RAMP\Modules\eventManager.js:423

Indicates that a map layer should be removed from the map

Event Payload: