catalogUtils

AMD: require(["esri/layers/catalog/catalogUtils"], (catalogUtils) => { /* code goes here */ });
ESM: import * as catalogUtils from "@arcgis/core/layers/catalog/catalogUtils.js";
Object: esri/layers/catalog/catalogUtils
Since: ArcGIS Maps SDK for JavaScript 4.30

Provides utility functions for the CatalogLayer.

See also

Method Overview

Name Return Type Summary Object

Utility method to get the parent CatalogLayer for a given layer in CatalogDynamicGroupLayer.layers collection.

catalogUtils

Utility method to check if the layer is temporarily available in the map and can be removed at any time because it is part of a CatalogLayer.

catalogUtils

Method Details

getCatalogLayerForLayer

Method
getCatalogLayerForLayer(layer){CatalogLayer |null |undefined}

Utility method to get the parent CatalogLayer for a given layer in CatalogDynamicGroupLayer.layers collection.

Parameter
layer Layer

The layer for which the CatalogLayer is to be retrieved.

Returns
Type Description
CatalogLayer | null | undefined The catalog for that layer when it can be found.
Example
// Highlight the footprint for a layer if it's part of a catalog dynamic grouplayer.
function highlightFootprintForLayer(view, layer) {
  const catalog = getCatalogLayerForLayer(layer);

  if (catalog) {
    const footprint = catalog.createFootprintFromLayer(layer);

    if (footprint) {
      const catalogLayerView = view.allLayerViews.find((layerView) => layerView.layer === catalog);
      return catalogLayerView?.footprintLayerView?.highlight(footprint);
    }
  }

  return { remove() {} };
}

isLayerFromCatalog

Method
isLayerFromCatalog(layer){Boolean}

Utility method to check if the layer is temporarily available in the map and can be removed at any time because it is part of a CatalogLayer.

It recursively checks if the layer's parent is CatalogLayer.

Use this utility to selectively exclude layers from your user experience. For example, to limit the options available for these layers in the LayerList.

Parameter
layer Layer

The layer to test.

Returns
Type Description
Boolean true if the layer or its parent is part of a catalog.
Example
// Get all layer not part of a catalog.
const layers = map.allLayers.filter((layer) => !isLayerFromCatalog(layer))

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.