require(["esri/widgets/LayerList/ListItem"], (LayerListItem) => { /* code goes here */ });
import LayerListItem from "@arcgis/core/widgets/LayerList/ListItem.js";
esri/widgets/LayerList/ListItem
The ListItem class represents one of the operationalItems in the LayerListViewModel. 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
listMode property on the desired layers to hide
.
You cannot hide list items using this class or the LayerList class.
- See also
Property Overview
Name | Type | Summary | Class |
---|---|---|---|
Whether the actions panel is open in the LayerList. | ListItem | ||
A nested 2-dimensional collection of actions that could be triggered on the item. | ListItem | ||
When a layer contains sublayers, this property is a Collection of ListItem objects belonging to the given layer. | ListItem | ||
Indicates if the children of a list item (or sublayers in a GroupLayer) can be sorted or moved/reordered. | ListItem | ||
Only valid when the list item represents a StreamLayer. | ListItem | ||
The name of the class. | Accessor | ||
The Error object returned if an error occurred. | ListItem | ||
When | ListItem | ||
The layer associated with the triggered action. | ListItem | ||
ListItem | |||
Specifies whether to ignore the listMode property of the child layers in the list item. | ListItem | ||
Whether the layer is open in the LayerList. | ListItem | ||
Allows you to display custom content for each ListItem in the LayerList widget. | ListItem | ||
The parent of this item | ListItem | ||
Value is | ListItem | ||
Indicates if the list item (or layer in the map) can be sorted or moved/reordered. | ListItem | ||
The title of the layer. | ListItem | ||
Value is | ListItem | ||
The view from which the widget will operate. | ListItem | ||
Indicates how to manage the visibility of the children layers. | ListItem | ||
Indicates if the ListItem is visible. | ListItem | ||
Whether the layer is visible at the current scale or not. | ListItem | ||
Whether the layer is visible at the current time extent or not. | ListItem |
Property Details
-
actionsOpen
actionsOpen Boolean
-
Whether the actions panel is open in the LayerList.
- Default Value:false
-
actionsSections
actionsSections Collection<Collection<(ActionButton|ActionToggle)>>autocast
-
A nested 2-dimensional collection of actions that could be triggered on the item.
-
children
children Collection<ListItem>
-
When a layer contains sublayers, this property is a Collection of ListItem objects belonging to the given layer.
-
childrenSortable
childrenSortable Boolean
Since: ArcGIS Maps SDK for JavaScript 4.16ListItem since 4.2, childrenSortable added at 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
connectionStatus Stringreadonly
Since: ArcGIS Maps SDK for JavaScript 4.24ListItem since 4.2, connectionStatus added at 4.24. -
Only valid when the list item represents a StreamLayer. Indicates the 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 isconnected
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 connectionStatus can be
paused
. This also results in displaying an orange offline icon next to the list item title.Possible Values:"connected" |"disconnected" |"paused"
-
error
error Errorreadonly
-
The Error object returned if an error occurred.
-
hidden
hidden Boolean
ListItem since 4.2, hidden added at 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
Examplelet 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; } } });
-
layer
layer Layer
-
The layer associated with the triggered action.
- Default Value:null
-
layerView
layerView LayerViewreadonly
-
-
listModeDisabled
listModeDisabled Boolean
Since: ArcGIS Maps SDK for JavaScript 4.30ListItem since 4.2, listModeDisabled added at 4.30. -
Specifies whether to ignore the 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'slistMode
value.- Default Value:false
- See also
-
open
open Boolean
-
Whether the layer is open in the LayerList.
- Default Value:false
-
panel
panel ListItemPanel
Since: ArcGIS Maps SDK for JavaScript 4.7ListItem since 4.2, panel added at 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 content property of the panel 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"), className: "esri-icon-chart", open: item.visible }; } });
-
parent
parent ListItem
Since: ArcGIS Maps SDK for JavaScript 4.5ListItem since 4.2, parent added at 4.5. -
The parent of this item
- Default Value:null
-
publishing
publishing Booleanreadonly
Since: ArcGIS Maps SDK for JavaScript 4.25ListItem since 4.2, publishing added at 4.25. -
Value is
true
when the layer is being published. Value will befalse
if the layer is not being published or checkPublishStatusEnabled isfalse
.- Default Value:false
-
sortable
sortable Boolean
Since: ArcGIS Maps SDK for JavaScript 4.16ListItem since 4.2, sortable added at 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
title String
-
The title of the layer.
-
updating
updating Booleanreadonly
-
Value is
true
when the layer is updating; for example, if it is in the process of fetching data.- Default Value:false
-
visibilityMode
visibilityMode Stringreadonly
-
Indicates how to manage the visibility of the children layers.
-
visible
visible Boolean
-
Indicates if the ListItem is visible.
- Default Value:true
-
visibleAtCurrentScale
visibleAtCurrentScale Booleanreadonly
-
Whether the layer is visible at the current scale or not.
- Default Value:true
-
visibleAtCurrentTimeExtent
visibleAtCurrentTimeExtent Booleanreadonly
Since: ArcGIS Maps SDK for JavaScript 4.30ListItem since 4.2, visibleAtCurrentTimeExtent added at 4.30. -
Whether the layer is visible at the current time extent or not.
- Default Value:true
Method Overview
Name | Return Type | Summary | Class |
---|---|---|---|
Adds one or more handles which are to be tied to the lifecycle of the object. | Accessor | ||
Creates a deep clone of this object. | ListItem | ||
Returns true if a named group of handles exist. | Accessor | ||
Removes a group of handles owned by the object. | Accessor |
Method Details
-
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25Accessor since 4.0, addHandles added at 4.25. -
Adds one or more handles which are to be tied to the lifecycle of the object. The handles will be removed when the object is destroyed.
// Manually manage handles const handle = reactiveUtils.when( () => !view.updating, () => { wkidSelect.disabled = false; }, { once: true } ); this.addHandles(handle); // Destroy the object this.destroy();
ParametershandleOrHandles WatchHandle|WatchHandle[]Handles marked for removal once the object is destroyed.
groupKey *optionalKey identifying the group to which the handles should be added. All the handles in the group can later be removed with Accessor.removeHandles(). If no key is provided the handles are added to a default group.
-
clone
clone(){ListItem}
-
Creates a deep clone of this object.
Returns
-
hasHandles
InheritedMethodhasHandles(groupKey){Boolean}
Inherited from AccessorSince: ArcGIS Maps SDK for JavaScript 4.25Accessor since 4.0, hasHandles added at 4.25. -
Returns true if a named group of handles exist.
ParametergroupKey *optionalA group key.
ReturnsType Description Boolean Returns true
if a named group of handles exist.Example// Remove a named group of handles if they exist. if (obj.hasHandles("watch-view-updates")) { obj.removeHandles("watch-view-updates"); }
-
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25Accessor since 4.0, removeHandles added at 4.25. -
Removes a group of handles owned by the object.
ParametergroupKey *optionalA group key or an array or collection of group keys to remove.
Exampleobj.removeHandles(); // removes handles from default group obj.removeHandles("handle-group"); obj.removeHandles("other-handle-group");