import ListItem from "@arcgis/core/widgets/LayerList/ListItem.js";const ListItem = await $arcgis.import("@arcgis/core/widgets/LayerList/ListItem.js");- Inheritance:
- ListItem→
Accessor
- 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.
Constructors
Constructor
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| properties | | |
Properties
| Property | Type | Class |
|---|---|---|
| | ||
| | ||
| | ||
| | ||
connectionStatus readonly | ConnectedLayerView["connectionStatus"] | null | undefined | |
declaredClass readonly inherited | ||
error readonly | | |
| | ||
incompatible readonly | | |
Layer | Sublayer | SubtypeSublayer | SubtypeGroupLayer | null | undefined | | |
layerView readonly | | |
| | ||
| | ||
| | ||
| | ||
publishing readonly | | |
| | ||
| | ||
uid readonly inherited | ||
updating readonly | | |
| | ||
visibilityMode readonly | | |
| | ||
visibleAtCurrentScale readonly | | |
visibleAtCurrentTimeExtent readonly | |
actionsOpen
- Type
- boolean
Whether the actions panel is open in the LayerList.
- Default value
- false
actionsSections
- Type
- Collection<Collection<Action>>
A nested 2-dimensional collection of actions that could be triggered on the item.
children
- Type
- Collection<ListItem>
When a layer contains sublayers, this property is a Collection of ListItem objects belonging to the given layer.
childrenSortable
- 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 sortedlistItem.childrenSortable = false; connectionStatus
- 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.
hidden
- 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
- Type
- boolean
- Since
- ArcGIS Maps SDK for JavaScript 4.32
Whether the layer is unsupported by the view.
- Default value
- false
layer
- Type
- Layer | Sublayer | SubtypeSublayer | SubtypeGroupLayer | null | undefined
The layer associated with the triggered action.
layerView
- Type
- LayerView | SpatiallyReferencedLayerView | ConnectedLayerView | null | undefined
listModeDisabled
- 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
panel
- 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 itemconst layerList = new LayerList({ view: view, listItemCreatedFunction: function(event){ const item = event.item; item.panel = { content: "legend" }; }});// displays content from the DOM in the LayerListconst layerList = new LayerList({ view: view, listItemCreatedFunction: function(event){ const item = event.item; item.panel = { content: document.getElementById("myDiv"), icon: "pie-chart", open: item.visible }; }}); publishing
- 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
- 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 sortedlistItem.sortable = false; uid
- Type
- string
- 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
- 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
- Type
- MapViewOrSceneView | null | undefined
The view from which the widget will operate.
visibleAtCurrentScale
- Type
- boolean
Whether the layer is visible at the current scale or not.
- Default value
- true
visibleAtCurrentTimeExtent
- 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
Type definitions
SpatiallyReferencedLayerView
- 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
- Type
- boolean
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Indicates if the layer view supports the current spatial reference.
ConnectedLayerView
- 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
ListItemVisibilityMode
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"