Skip to content
import ListItem from "@arcgis/core/widgets/LayerList/ListItem.js";
Inheritance:
ListItemAccessor
Since
ArcGIS Maps SDK for JavaScript 4.2

The ListItem class represents one of the LayerListViewModel.operationalItems. In the LayerList widget UI, the list item represents a layer displayed in the view. It provides access to the associated layer's properties, allows the developer to configure actions related to the layer, and allows the developer to add content to the item related to the layer.

To hide list items in the LayerList widget, you must set the Layer.listMode property to hide on the desired layers. You cannot hide list items using this class or the LayerList class.

See also

Constructors

Constructor

Constructor
Parameters
ParameterTypeDescriptionRequired
properties
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.

actionsOpen

Property
Type
boolean

Whether the actions panel is open in the LayerList.

Default value
false

actionsSections

autocast Property
Type
Collection<Collection<Action>>

A nested 2-dimensional collection of actions that could be triggered on the item.

See also

children

autocast Property
Type
Collection<ListItem>

When a layer contains sublayers, this property is a Collection of ListItem objects belonging to the given layer.

childrenSortable

Property
Type
boolean
Since
ArcGIS Maps SDK for JavaScript 4.16

Indicates if the children of a list item (or sublayers in a GroupLayer) can be sorted or moved/reordered.

Default value
true
Example
// disables the children of a parent list item from being sorted
listItem.childrenSortable = false;

connectionStatus

readonly Property
Type
ConnectedLayerView["connectionStatus"] | null | undefined
Since
ArcGIS Maps SDK for JavaScript 4.24

Only valid when the list item represents a StreamLayer. Indicates the StreamLayerView.connectionStatus of the stream layer connection. This overrides the updating property.

Starting at version 4.27, a green beacon icon will appear next to the list item title when a stream layer is connected. Prior to version 4.27, when a stream layer is connected a green calcite check-circle icon will appear next to the list item title.

When a stream layer is disconnected an orange calcite offline icon will display next to the list item title.

Starting at version 4.26, the StreamLayerView.connectionStatus can be paused. This also results in displaying an orange offline icon next to the list item title.

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.

error

readonly Property
Type
EsriError | null | undefined

The Error object returned if an error occurred.

hidden

Property
Type
boolean
Since
ArcGIS Maps SDK for JavaScript 4.24

When true, hides the layer from the LayerList instance. This is an alternative to Layer.listMode, which hides a layer from all instances of LayerList that include the layer.

Default value
false
Example
let layerList1 = new LayerList({
view,
container: layerList1Container,
listItemCreatedFunction: (event) => {
// hides the USA - Highway layer from the
// layerList1 instance of layerlist
if(event.item.title === "USA - Highways") {
event.item.hidden = true;
}
}
});

incompatible

readonly Property
Type
boolean
Since
ArcGIS Maps SDK for JavaScript 4.32

Whether the layer is unsupported by the view.

Default value
false

layer

Property
Type
Layer | Sublayer | SubtypeSublayer | SubtypeGroupLayer | null | undefined

The layer associated with the triggered action.

layerView

readonly Property
Type
LayerView | SpatiallyReferencedLayerView | ConnectedLayerView | null | undefined

The LayerView displaying data for the associated layer.

listModeDisabled

Property
Type
boolean
Since
ArcGIS Maps SDK for JavaScript 4.30

Specifies whether to ignore the Layer.listMode property of the child layers in the list item. A common use case for listModeDisabled is when you want to use the LayerList or BasemapLayerList to manage and configure a layer's listMode value.

See also
Default value
false

open

Property
Type
boolean

Whether the layer is open in the LayerList.

Default value
false

panel

autocast Property
Type
ListItemPanel
Since
ArcGIS Maps SDK for JavaScript 4.7

Allows you to display custom content for each ListItem in the LayerList widget.

A common scenario for using ListItemPanel is to display a Legend widget within each list item. The legend keyword can be used in the ListItemPanel.content property to display a legend for each layer in the LayerList.

Examples
// displays the legend for each layer list item
const layerList = new LayerList({
view: view,
listItemCreatedFunction: function(event){
const item = event.item;
item.panel = {
content: "legend"
};
}
});
// displays content from the DOM in the LayerList
const layerList = new LayerList({
view: view,
listItemCreatedFunction: function(event){
const item = event.item;
item.panel = {
content: document.getElementById("myDiv"),
icon: "pie-chart",
open: item.visible
};
}
});

parent

Property
Type
ListItem | null | undefined
Since
ArcGIS Maps SDK for JavaScript 4.5

The parent of this item

publishing

readonly Property
Type
boolean
Since
ArcGIS Maps SDK for JavaScript 4.25

Value is true when the layer is being published. Value will be false if the layer is not being published or LayerListViewModel.checkPublishStatusEnabled is false.

Default value
false

sortable

Property
Type
boolean
Since
ArcGIS Maps SDK for JavaScript 4.16

Indicates if the list item (or layer in the map) can be sorted or moved/reordered.

Default value
true
Example
// disables the list item from being sorted
listItem.sortable = false;

title

autocast Property
Type
string

The title of the layer.

uid

readonlyinherited Property
Type
string
Inherited from: IdentifiableMixin
Since
ArcGIS Maps SDK for JavaScript 4.33

An automatically generated unique identifier assigned to the instance. The unique id is generated each time the application is loaded.

updating

readonly Property
Type
boolean

Value is true when the layer is updating; for example, if it is in the process of fetching data.

Default value
false

view

Property
Type
MapViewOrSceneView | null | undefined

The view from which the widget will operate.

visibilityMode

readonly Property
Type
ListItemVisibilityMode

Indicates how to manage the visibility of the children layers.

visible

Property
Type
boolean

Indicates if the ListItem is visible.

Default value
true

visibleAtCurrentScale

readonly Property
Type
boolean

Whether the layer is visible at the current scale or not.

Default value
true

visibleAtCurrentTimeExtent

readonly Property
Type
boolean
Since
ArcGIS Maps SDK for JavaScript 4.30

Whether the layer is visible at the current time extent or not.

Default value
true

Methods

MethodSignatureClass
clone(): ListItem

clone

Method
Signature
clone (): ListItem

Creates a deep clone of this object.

Returns
ListItem

A clone of the new ListItem instance.

Type definitions

SpatiallyReferencedLayerView

Type definition
Since
ArcGIS Maps SDK for JavaScript 5.0

Represents a layer view that supports spatial referencing. Used to indicate whether the associated layer view can operate with a spatial reference in the current view context.

See also
Supertypes
default

spatialReferenceSupported

Property
Type
boolean
Since
ArcGIS Maps SDK for JavaScript 5.0

Indicates if the layer view supports the current spatial reference.

ConnectedLayerView

Type definition
Since
ArcGIS Maps SDK for JavaScript 5.0

Represents a layer view for stream layers that provides connection status information. Used to determine the current connection state of a stream layer in the view.

See also
Supertypes
default

connectionStatus

Property
Type
StreamLayerViewConnectionStatus
Since
ArcGIS Maps SDK for JavaScript 5.0

The current connection status of the stream layer view.

ListItemVisibilityMode

Type definition

Defines how the visibility of child layers is managed within a list item.

  • independent: Each child layer's visibility is controlled separately.
  • inherited: Child layers inherit the visibility from their parent layer.
  • exclusive: Only one child layer can be visible at a time.
See also
Type
"independent" | "inherited" | "exclusive"