import LayerListModel from "@arcgis/core/layerList/LayerListModel.js";
Inheritance
LayerListModel→Accessor
Since
ArcGIS Maps SDK for JavaScript 5.2
beta

Manages the Item instances displayed for operational layers in a layer-list workflow. The collection tracks the view's layers and layer views, creates and updates list items, and supports custom item configuration, actions, visibility filtering, and reordering. To exclude a layer from the collection, set its Layer.listMode property to hide.

Constructors

Constructor

Constructor

Parameters

ParameterTypeDescriptionRequired
properties

The properties used to configure the collection.

See the properties table for a list of all the properties that may be passed into the constructor.

Properties

Any properties can be set, retrieved or listened to. See the Watch for changes topic.

checkPublishStatusEnabled

Property
Type
boolean

Indicates whether items should report when their associated layers are being published. When false, the Item.publishing property is always false.

Default value
false

declaredClass

readonlyinherited Property
Type
string
Inherited from: Accessor
Since
ArcGIS Maps SDK for JavaScript 4.7

The name of the class. The declared class name is formatted as esri.folder.className.

listItemCreatedFunction

Property
Type
ItemModifier | null | undefined

A function called when each Item is created. Use the callback to modify supported item properties or add actions through the Item.actionsSections property.

listModeDisabled

Property
Type
boolean

Indicates whether to ignore the Layer.listMode property when determining which layers to display. When true, layers with a listMode of hide are included.

See also
Default value
false

operationalItems

readonly Property
Type
Collection<Item>

The items representing operational layers in the view. Items are ordered to match the map's layer order and can include nested child items. To exclude a layer, set its Layer.listMode property to hide.

See also

state

readonly Property
Type
State

The current state of the collection. Returns disabled when no view is set, loading while the view is not ready, and ready when the view is ready to provide operational layer items.

Default value
"disabled"

totalItems

readonly Property
Type
number

The total number of items, including nested child items.

view

Property
Type
MapViewOrSceneView | null | undefined

The map or scene view that supplies the operational layers and layer views for this collection.

Methods

MethodSignatureClass
inherited
emit<Type extends EventNames<this>>(type: Type, event?: this["@eventTypes"][Type]): boolean
inherited
hasEventListener<Type extends EventNames<this>>(type: Type): boolean
moveItem(targetItem: Item | null | undefined, fromParentItem: Item | null | undefined, toParentItem: Item | null | undefined, newIndex: number): void
on
inherited
on<Type extends EventNames<this>>(type: Type, listener: EventedCallback<this["@eventTypes"][Type]>): ResourceHandle
triggerAction(action: Action, item: Item): void

emit

inherited Method
Signature
emit <Type extends EventNames<this>>(type: Type, event?: this["@eventTypes"][Type]): boolean
Type parameters
<Type extends EventNames<this>>
Inherited from: EventedMixin
Since
ArcGIS Maps SDK for JavaScript 4.5

Emits an event on the instance. This method should only be used when creating subclasses of this class.

Parameters

ParameterTypeDescriptionRequired
type
Type

The name of the event.

event
this["@eventTypes"][Type]

The event payload.

Returns
boolean

true if a listener was notified

hasEventListener

inherited Method
Signature
hasEventListener <Type extends EventNames<this>>(type: Type): boolean
Type parameters
<Type extends EventNames<this>>
Inherited from: EventedMixin

Indicates whether there is an event listener on the instance that matches the provided event name.

Parameters

ParameterTypeDescriptionRequired
type
Type

The name of the event.

Returns
boolean

Returns true if the class supports the input event.

moveItem

Method
Signature
moveItem (targetItem: Item | null | undefined, fromParentItem: Item | null | undefined, toParentItem: Item | null | undefined, newIndex: number): void

Moves a layer item within the map or between supported parent layers. The item must represent a layer, and sublayers cannot be moved with this method. The target index uses the layer collection's order, where 0 represents the top position in the list.

Parameters

ParameterTypeDescriptionRequired
targetItem

The item to move.

fromParentItem

The item's current parent, if it has one.

toParentItem

The target parent, if the item is being moved into a child collection.

newIndex

The target position in the destination collection.

Returns
void

on

inherited Method
Signature
on <Type extends EventNames<this>>(type: Type, listener: EventedCallback<this["@eventTypes"][Type]>): ResourceHandle
Type parameters
<Type extends EventNames<this>>
Inherited from: EventedMixin

Registers an event handler on the instance. Call this method to hook an event with a listener.

Parameters

ParameterTypeDescriptionRequired
type
Type

An event or an array of events to listen for.

listener
EventedCallback<this["@eventTypes"][Type]>

The function to call when the event fires.

Returns
ResourceHandle

Returns an event handler with a remove() method that should be called to stop listening for the event(s).

PropertyTypeDescription
removeFunctionWhen called, removes the listener from the event.
Example
view.on("click", function(event){
// event is the event handle returned after the event fires.
console.log(event.mapPoint);
});

triggerAction

Method
Signature
triggerAction (action: Action, item: Item): void

Executes an enabled action associated with an item and emits the @trigger-action event. Disabled actions are ignored.

Parameters

ParameterTypeDescriptionRequired
action

The action to execute.

item

The item associated with the action.

Returns
void

Events

trigger-action

Event

Emitted when the user clicks an action or action toggle in a layer list. Use this event to run custom logic when a specific action is triggered. The event object is a LayerListModelTriggerActionEvent.

See also
bubbles composed cancelable

Type definitions