Skip to content

📦 core ​

This package provides the foundation for the Geospatial SDK.

It includes:

  • Map Context model: TypeScript types and interfaces for declaratively defining maps, layers, and views
  • Diff algorithms: Utilities to compute differences between Map Context objects (computeMapContextDiff)
  • Validation utilities: Tools for working with and validating geospatial data
  • Shared constants: Common definitions used across all packages

The @geospatial-sdk/core package is framework-agnostic and does not depend on any specific mapping library. It's required by all other packages in the SDK.

Installation ​

sh
npm install @geospatial-sdk/core

Usage ​

typescript
import { computeMapContextDiff, type MapContext } from "@geospatial-sdk/core";

const oldContext: MapContext = {
  layers: [{ type: "xyz", url: "https://example.com/{z}/{x}/{y}.png" }],
  view: { center: [0, 0], zoom: 2 },
};

const newContext: MapContext = {
  layers: [{ type: "xyz", url: "https://example.com/{z}/{x}/{y}.png" }],
  view: { center: [5, 45], zoom: 5 },
};

const diff = computeMapContextDiff(newContext, oldContext);

Classes ​

ClassDescription
SourceLoadErrorEvent-

Interfaces ​

InterfaceDescription
FeaturesClickEvent-
FeaturesHoverEvent-
LayerCreationErrorEvent-
LayerGeojsonWithData-
LayerGeojsonWithUrl-
LayerLoadingErrorEvent-
MapClickEvent-
MapContextA map context, containing layers and a view.
MapContextBaseLayer-
MapContextDiffDescribes a delta between two contexts, in order to be applied to an existing map.
MapContextLayerChangedDescribes a layer that was changed: both states before and after change are included
MapContextLayerGeotiff-
MapContextLayerMapLibreStyle-
MapContextLayerPositionedAssociates a position to a layer; the position is the index of the layer in the layers array
MapContextLayerReorderedDescribes a layer being moved to a different position
MapContextLayerVector-
MapContextLayerWms-
MapContextLayerWmts-
MapContextLayerXyz-
MapEventsByType-
MapExtentChangeEvent-
MapLayerDataInfo-
MapLayerStateChangeEvent-
MapStateChangeEvent-
MapViewStateChangeEvent-
ResolvedMapStateDescribes the actual state of a map after a context or context diff was applied to it. A view of null means the view state hasn't been changed yet. A layer item of null means the layer state hasn't been changed yet.
ResolvedMapViewStateDescribes the actual view state of a map
ViewByExtent-
ViewByGeometry-
ViewByZoomAndCenter-

Type Aliases ​

Type AliasDescription
Coordinate-
ExtentArray components are respectively: minX, minY, maxX, maxY
FeaturesByLayerIndex-
LayerDimensionValueRange-
LayerDimensionValueSingle-
LayerGeojson-
MapContextLayerA layer that can be used in a map context.
MapContextLayerGeojson-
MapContextLayerOgcApi-
MapContextLayerWfs-
MapContextViewA description of a map viewport in one of three ways: * by center and zoom level, * by extent, * by geometry (in GeoJSON)
MapLayerCreationStatus-
MapLayerLoadingStatus-
ResolvedMapLayerState-
VectorStyle-

Variables ​

VariableDescription
defaultHighlightStyle-
defaultStyle-
FeaturesClickEventType-
FeaturesHoverEventType-
LayerCreationErrorEventType-
LayerLoadingErrorEventType-
MapClickEventType-
MapExtentChangeEventTypeDEPRECATED Use the MapViewStateChangeEvent instead
MapLayerStateChangeEventType-
MapStateChangeEventType-
MapViewStateChangeEventType-
SourceLoadErrorTypeDEPRECATED Use the MapLayerStateChangeEvent and LayerLoadingErrorEvent instead

Functions ​

FunctionDescription
addLayerToContextAdds a layer to the context at a specific position or at the end if no position is specified.
changeLayerPositionInContextChanges the position of a layer in the context.
computeMapContextDiffThe following logic is produced by identifying layers in both context and determining whether they have been added, removed, changed or reordered.
createViewFromLayerCreates a view from a layer by extracting its geographic extent. The returned extent is always expressed in EPSG:4326 (longitude/latitude) coordinates.
deepFreeze-
getHash-
getLayerPosition-
removeLayerFromContextRemoves a layer from the context.
removeSearchParamsRemoves the given search params from the URL completely; this is case-insensitive
replaceLayerInContextReplaces a layer in the context with a new layer.
updateLayerApplies the updates partial to the given layer. The layer will also be adjusted depending on the presence of the id and version fields. Note: any property set to undefined in updates will be removed from the resulting layer.
updateLayerInContextUpdates an existing layer in the context by applying partial changes.