Skip to content

Catalog

Overview

useCatalog(options) provides reactive access to catalog data (layers, categories, sublegends, and views) from the KDK catalog FeathersJS service. It exposes async fetch functions and computed properties that organize layers by category and identify orphan layers.

Usage

javascript
import { useCatalog } from '@kalisio/kdk/map.client'

const {
  layers, categories, sublegends, views,
  layersByCategory, orphanLayers,
  getLayers, getCategories, getSublegends, getViews
} = useCatalog({
  layers: { scope: 'user' },
  context: 'myOrg'
})

// Fetch data
await getLayers()
await getCategories()

Parameters

ParameterTypeDefaultDescription
options.layersObject{}Default filter query applied when retrieving layers from the catalog.
options.categoriesObject{}Default filter query applied when retrieving categories.
options.sublegendsObject{}Default filter query applied when retrieving sublegends.
options.viewsObject{}Default filter query applied when retrieving views (contexts).
options.contextstring''Context ID for the catalog service (used for contextual/multi-tenant services).
options.projectObjectOptional project object. When provided, catalog queries are automatically scoped to that project's layers and views.
options.planetApiObjectapiThe client API instance used to reach the catalog service.

Exposed

NameTypeDescription
layersRef<Array>The retrieved set of layers from the catalog.
categoriesRef<Array>The retrieved set of categories from the catalog.
sublegendsRef<Array>The retrieved set of sublegends from the catalog.
viewsRef<Array>The retrieved set of views (contexts) from the catalog.
layersByCategoryComputedRef<Object>Layers organized by category name; keys are category names and values are arrays of matching layers.
orphanLayersComputedRef<Array>Layers that do not belong to any category, sorted by _id.
getLayers(filterQuery?)async FunctionFetches layers from the catalog, merging the optional filterQuery with options.layers. Updates layers.
getCategories()async FunctionFetches categories from the catalog using options.categories. Updates categories.
getSublegends()async FunctionFetches sublegends from the catalog using options.sublegends. Updates sublegends.
getViews()async FunctionFetches views from the catalog using options.views. Updates views.