LayerNode class

The LayerNode class is an abstraction of the layer object from ArcGIS API for JavaScript. It contains the reference to the parent or child layers and allows you to access layers using a unified interface regardless of the root layer, sublayer, or layer type such as FeatureLayer, ArcGISDynamicMapServiceLayer, KMLLayer, and so on.

AMD Module Require

require(["jimu/LayerNode"], function(LayerNode) { /* code goes here */ });

Constructor

LayerNode has no constructor. It can only be retrieved from LayerStructure.

Constants

EVENT_TOGGLE_CHANGE

Event name for a toggle change.

EVENT_VISIBILITY_CHANGE

Event name for a visibility change.

EVENT_FILTER_CHANGE

Event name for a filter change.

EVENT_RENDERER_CHANGE

Event name for a renderer change.

EVENT_OPACITY_CHANGE

Event name for an opacity change.

Properties

<esri/map> map

The current web map object.

<String> title

The title of the current layerNode.

<String> id

The ID of the current layerNode.

<String> subId

The subID of the current layerNode

Methods

canShowLabel()

Returns true if the layer can show a label.

Parameters: null

Return value: Boolean

disablePopup()

Disables the pop-up.

Parameters: null

Return value: Boolean—Returns true to disable the pop-up; returns false to enable it.

enablePopup()

Enables the pop-up.

Parameters: null

Return value: Boolean—Returns true to enable the pop-up; returns false to disable it.

getExtent()

Gets the extent of the current layerNode.

Parameters: null

Return value:

Deferred;

Resolve value: Extent

getFilterFromWebmap()

Gets the definition expression from the web map.

Parameters: null

Return value:

JSON;

null—Returns null if the definition expression isn't defined in the web map.

getFilter()

Gets the definition expression from the current layer.

Parameters: null

Return value:

JSON;

null—Returns null if the layer doesn't have a definition expression.

getInfoTemplate()

Gets the infoTemplate from the current layer.

Parameters: null

Return value:

JSON;

null—Returns null if the layer doesn't have an infoTemplate.

getLayerObject()

Gets the current layer object.

Parameters: null

Return value:

Deferred;

Resolve value: Layer; null—Resolves null if the layer object fails to load.

getLayerType()

Gets the current layer type.

Parameters: null

Return value:

Deferred;

Resolve value: String

getNodeById(nodeId)

Gets the node or subnode by ID.

Parameters: nodeId—node or subNode ID.

Return value: LayerNode

getOpacity()

Gets the opacity of the current layer.

Parameters: null

Return value: Integer

getParentNode()

Gets the parent node of the current layerNode.

Parameters: null

Return value:

LayerNode;

null—Returns null if the current layer is a rootLayer.

getPopupInfo()

Gets the pop-up information from the current layer.

Parameters: null

Return value:

JSON;

null—Returns null if the layer doesn't have pop-up information.

getPopupInfoFromWebmap()

Gets the pop-up information from the web map.

Parameters: null

Return value:

JSON;

null—Returns null if the pop-up information isn't defined in the web map.

getRelatedNodes()

Gets the related layerNodes array associated with the current layer.

Parameters: null

Return value:

Deferred;

resolve value: LayerNode[]

getRootNode()

Gets the root node of the current layerNode.

Parameters: null

Return value: LayerNode

getServiceDefinition()

Gets the service definition from the server.

Parameters: null

Return value:

Deferred;

resolve value: JSON or XML; null—Resolves null if the service definition fails to load.

getSubNodes()

Gets the subNodes of the current layerNode.

Parameters: null

Return value: LayerNode[]

getUrl()

Gets the URL of the current layer.

Parameters: null

Return value:

String;

null—Returns null if the layer doesn't have a URL.

hide()

Makes the current layer invisible on the map.

Parameters: null

Return value: null

hideLabel()

Hides the labels on the map.

Parameters: null

Return value: null

isHostedLayer()

Returns true if the layer is a hosted layer.

Parameters: null

Return value:

Deferred;

Resolve value: Boolean

isItemLayer()

Returns basic item information if the layer is an item layer; otherwise it returns null.

Parameters: null

Return value:

  basicItemInfo = {
    portalUrl:
    itemId:
  }

isLabelVisble()

Returns true if the layer's label is visible.

Parameters: null

Return value: Boolean

isLeaf()

Returns true if the node is a leaf node.

Parameters: null

Return value: Boolean

isPopupEnabled()

Returns true if the pop-up is enabled.

Parameters: null

Return value: Boolean

isRoot()

Returns true if the node is a root node.

Parameters: null

Return value: Boolean

isShowLegend()

Determines if a legend is showing in the current layer.

Parameters: null

Return value: Boolean

isShowLegendFromWebmap()

Determines if a legend is showing in the web map.

Parameters: null

Return value: Boolean

isTable()

Returns true if the current layer is a table.

Parameters: null

Return value: Boolean

isTiled()

Returns true if the current layer is tiled. Currently, it only supports tiled map service layers.

Parameters: null

Return value: Boolean

isToggledOn()

Returns true if the layerNode is toggled on.

Parameters: null

Return value: Boolean

isVisible()

Returns true if the layer is visible.

Parameters: null

Return value: Boolean

isVisibleAtMapScale()

Returns true if the layer is visible at the current map scale.

Parameters: null

Return value: Boolean

loadInfoTemplate()

Gets the infoTemplate from the current layer if available, and attempts to load the default infoTemplate if the layer doesn't already have it.

Parameters: null

Return value:

Deferred;

resolve value: JSON; null—Returns null if the infoTemplate fails to load.

loadPopupInfo()

Gets the pop-up information from the current layer if available, and attempts to load the default pop-up information if the layer doesn't already have it.

Parameters: null

Return value:

Deferred;

resolve value: JSON; null—Returns null if the PopupInfo fails to load.

setFilter(layerDefinitionExpression)

Sets the definition expression for the current layer.

Parameters: String

Return value: null

setOpacity(opacity)

Sets the opacity for the current layer.

Parameters:

opacity: Integer

Return value: null

show()

Makes the current layer visible on the map.

Parameters: null

Return value: null

showLabel()

Shows the labels on the map.

Parameters: null

Return value: null

toggle()

Toggle layerNode. The layer shows if all parent nodes on the path are toggled on.

Parameters: null

Return value: null

traversal(callback)

Traverses all nodes of the current layerNode with Depth-First-Search.

Parameters: callback: function(layerNode) {};

Callback parameters: layerNode

Callback return value: Boolean—Returns true when the traversal is interrupted; returns false when the traversal continues.

Return value: Boolean—Returns true when the traversal is interrupted; returns false when the traversal is complete.

Events

toggle-change

Fires when the layerNode toggle is changed.

Event object: null

See also: EVENT_TOGGLE_CHANGE in the Constants table

visibility-change

Fires when the visibility of layerNode is changed.

Event object: null

See also: EVENT_TOGGLE_CHANGE in the Constants table.

filter-change

Fires when the layerNode filter is changed.

Event object: null

See also: EVENT_FILTER_CHANGE in the Constants table.

renderer-change

Fires when the layerNode renderer is changed.

Event object: null

See also: EVENT_RENDERER_CHANGE in the Constants table.

opacity-change

Fires when the layerNode opacity is changed.

Event object: null

See also: EVENT_OPACITY_CHANGE in the Constants table.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.