UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

125 lines (122 loc) 6.53 kB
import type Collection from "../../core/Collection.js"; import type CatalogLayer from "../../layers/CatalogLayer.js"; import type ListItem from "../LayerList/ListItem.js"; import type { EventedAccessor } from "../../core/Evented.js"; import type { MapViewOrSceneView } from "../../views/MapViewOrSceneView.js"; import type { CatalogLayerListState } from "./types.js"; import type { LayerListViewModelEvents } from "../LayerList/LayerListViewModel.js"; import type { Action, ListItemModifier } from "../LayerList/types.js"; export interface CatalogLayerListViewModelProperties extends Partial<Pick<CatalogLayerListViewModel, "catalogLayer" | "checkPublishStatusEnabled" | "listItemCreatedFunction" | "listModeDisabled" | "view">> {} export interface CatalogLayerListViewModelEvents extends LayerListViewModelEvents {} /** * Provides the logic for the [CatalogLayerList](https://developers.arcgis.com/javascript/latest/references/core/widgets/CatalogLayerList/) widget and [component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-catalog-layer-list/). * * @since 4.30 * @see [CatalogLayerList](https://developers.arcgis.com/javascript/latest/references/core/widgets/CatalogLayerList/) widget * @see [Catalog Layer List component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-catalog-layer-list/) */ export default class CatalogLayerListViewModel extends EventedAccessor { /** * @deprecated * Do not directly reference this property. * Use EventNames and EventTypes helpers from \@arcgis/core/Evented */ "@eventTypes": CatalogLayerListViewModelEvents; constructor(properties?: CatalogLayerListViewModelProperties); /** * The collection of [ListItems](https://developers.arcgis.com/javascript/latest/references/core/widgets/LayerList/ListItem/) representing the [catalogLayer's](https://developers.arcgis.com/javascript/latest/references/core/widgets/CatalogLayerList/CatalogLayerListViewModel/#catalogLayer) * [CatalogLayer.dynamicGroupLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/CatalogLayer/#dynamicGroupLayer). * * @see [CatalogLayerList.selectedItems](https://developers.arcgis.com/javascript/latest/references/core/widgets/CatalogLayerList/#selectedItems) */ get catalogItems(): Collection<ListItem>; /** * The [CatalogLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/CatalogLayer/) to display in the widget. * * @example catalogLayerList.catalogLayer = new CatalogLayer({ url }); */ accessor catalogLayer: CatalogLayer | null | undefined; /** * Whether to provide an indication if a layer is being published in the * [CatalogLayerList](https://developers.arcgis.com/javascript/latest/references/core/widgets/CatalogLayerList/). When a layer is publishing, * a rotating square will appear to the right of the list item title. * The list item * [ListItem.publishing](https://developers.arcgis.com/javascript/latest/references/core/widgets/LayerList/ListItem/#publishing) property * will be `false` if `checkPublishStatusEnabled` is `false`. * * @default false */ accessor checkPublishStatusEnabled: boolean; /** * A function that executes each time a [ListItem](https://developers.arcgis.com/javascript/latest/references/core/widgets/LayerList/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](https://developers.arcgis.com/javascript/latest/references/core/widgets/LayerList/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); * } * }); */ accessor listItemCreatedFunction: ListItemModifier | null | undefined; /** * Specifies whether to ignore the [Layer.listMode](https://developers.arcgis.com/javascript/latest/references/core/layers/Layer/#listMode) property to display all layers. * * @default false * @since 4.32 * @see [Layer.listMode](https://developers.arcgis.com/javascript/latest/references/core/layers/Layer/#listMode) */ accessor listModeDisabled: boolean; /** * The view model's state. * * @default "disabled" */ get state(): CatalogLayerListState; /** The view from which the widget will operate. */ accessor view: MapViewOrSceneView | null | undefined; /** * Triggers the [@trigger-action](https://developers.arcgis.com/javascript/latest/references/core/widgets/CatalogLayerList/CatalogLayerListViewModel/#event-trigger-action) event and executes * the given [action](https://developers.arcgis.com/javascript/latest/references/core/support/actions/ActionButton/) or [action toggle](https://developers.arcgis.com/javascript/latest/references/core/support/actions/ActionToggle/). * * @param action - The action to execute. * @param item - An item associated with the action. */ triggerAction(action: Action, item: ListItem): void; }