Skip to content
import CatalogLayerListViewModel from "@arcgis/core/widgets/CatalogLayerList/CatalogLayerListViewModel.js";
Inheritance:
CatalogLayerListViewModelAccessor
Since
ArcGIS Maps SDK for JavaScript 4.30

Provides the logic for the CatalogLayerList widget and component.

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.

catalogItems

readonly Property
Type
Collection<ListItem>

catalogLayer

Property
Type
CatalogLayer | null | undefined

The CatalogLayer to display in the widget.

Example
catalogLayerList.catalogLayer = new CatalogLayer({ url });

checkPublishStatusEnabled

Property
Type
boolean

Whether to provide an indication if a layer is being published in the CatalogLayerList. When a layer is publishing, a rotating square will appear to the right of the list item title. The list item ListItem.publishing property will be false if checkPublishStatusEnabled is false.

Default value
false

declaredClass

readonlyinherited Property
Type
string
Inherited from: Accessor

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

listItemCreatedFunction

Property
Type
ListItemModifier | null | undefined

A function that executes each time a ListItem is created. Use this function to add actions and panels to list items, and to override the default settings of a list item. Actions can be added to list items using the ListItem.actionsSections property of the ListItem.

Example
// Create a new CatalogLayerListViewModel with a listItemCreatedFunction
// that adds an "add-layer" action to each catalog layer list item
const catalogLayerListViewModel = new CatalogLayerListViewModel({
catalogLayer,
listItemCreatedFunction: (event) => {
const { item } = event;
const { layer } = item;
if (isLayerFromCatalog(layer)) {
item.actionsSections = [
[
{
title: "Add layer to map",
icon: "add-layer",
id: "add-layer"
}
]
];
}
},
view
});
// Listen for the trigger-action event on the CatalogLayerListViewModel
// and add layers from the catalog to the map when the "add-layer" action is triggered.
// To correctly add a layer to the map, you must create a footprint from the layer
// and then create a new layer from the footprint.
catalogLayerListViewModel.on("trigger-action", async (event) => {
const { id } = event.action;
const { layer } = event.item;
if (id === "add-layer") {
const parentCatalogLayer = catalogUtils.getCatalogLayerForLayer(layer);
const footprint = parentCatalogLayer.createFootprintFromLayer(layer);
const layerFromFootprint = await parentCatalogLayer.createLayerFromFootprint(footprint);
map.add(layerFromFootprint);
}
});

listModeDisabled

Property
Type
boolean
Since
ArcGIS Maps SDK for JavaScript 4.32

Specifies whether to ignore the Layer.listMode property to display all layers.

See also
Default value
false

state

readonly Property
Type
CatalogLayerListState

The view model's state.

Default value
"disabled"

view

Property
Type
MapViewOrSceneView | null | undefined

The view from which the widget will operate.

Methods

MethodSignatureClass
emit
inherited
emit<Type extends EventNames<this>>(type: Type, event?: this["@eventTypes"][Type]): boolean
hasEventListener
inherited
hasEventListener<Type extends EventNames<this>>(type: Type): boolean
on
inherited
on<Type extends EventNames<this>>(type: Type, listener: EventedCallback<this["@eventTypes"][Type]>): ResourceHandle
triggerAction(action: Action, item: ListItem): 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

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.

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: ListItem): void

Triggers the @trigger-action event and executes the given action or action toggle.

Parameters
ParameterTypeDescriptionRequired
action

The action to execute.

item

An item associated with the action.

Returns
void

Events

trigger-action

inherited 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.

See also
bubbles composed cancelable

Type definitions