import CatalogLayerListViewModel from "@arcgis/core/widgets/CatalogLayerList/CatalogLayerListViewModel.js";const CatalogLayerListViewModel = await $arcgis.import("@arcgis/core/widgets/CatalogLayerList/CatalogLayerListViewModel.js");- Inheritance
- CatalogLayerListViewModel→
Accessor
- Since
- ArcGIS Maps SDK for JavaScript 4.30
Provides the logic for the CatalogLayerList widget and component.
- See also
Constructors
Constructor
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| properties | | |
Properties
| Property | Type | Class |
|---|---|---|
| readonly | | |
| | ||
| | ||
| readonly inherited | ||
| | ||
| | ||
| readonly | | |
| |
catalogItems
- Type
- Collection<ListItem>
The collection of ListItems representing the catalogLayer's CatalogLayer.dynamicGroupLayer.
- See also
catalogLayer
- Type
- CatalogLayer | null | undefined
The CatalogLayer to display in the widget.
- Example
- catalogLayerList.catalogLayer = new CatalogLayer({ url });
checkPublishStatusEnabled
- 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
listItemCreatedFunction
- 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 itemconst 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
- 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
view
- Type
- MapViewOrSceneView | null | undefined
The view from which the widget will operate.
Methods
| Method | Signature | Class |
|---|---|---|
| inherited | emit<Type extends EventNames<this>>(type: Type, event?: this["@eventTypes"][Type]): boolean | |
| inherited | hasEventListener<Type extends EventNames<this>>(type: Type): boolean | |
| inherited | on<Type extends EventNames<this>>(type: Type, listener: EventedCallback<this["@eventTypes"][Type]>): ResourceHandle | |
| triggerAction(action: Action, item: ListItem): void | |
emit
- Signature
-
emit <Type extends EventNames<this>>(type: Type, event?: this["@eventTypes"][Type]): boolean
- Type parameters
- <Type extends EventNames<this>>
Emits an event on the instance. This method should only be used when creating subclasses of this class.
hasEventListener
- Signature
-
hasEventListener <Type extends EventNames<this>>(type: Type): boolean
- Type parameters
- <Type extends EventNames<this>>
Indicates whether there is an event listener on the instance that matches the provided event name.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| type | Type | The name of the event. | |
- Returns
- boolean
Returns true if the class supports the input event.
on
- Signature
-
on <Type extends EventNames<this>>(type: Type, listener: EventedCallback<this["@eventTypes"][Type]>): ResourceHandle
- Type parameters
- <Type extends EventNames<this>>
Registers an event handler on the instance. Call this method to hook an event with a listener.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| 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).Property Type Description remove Function When 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
- Signature
-
triggerAction (action: Action, item: ListItem): void
Triggers the @trigger-action event and executes the given action or action toggle.
Events
| Name | Type |
|---|---|
| inherited |
trigger-action
trigger-action: CustomEvent<LayerListViewModelTriggerActionEvent> 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.