📦 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/coreUsage ​
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 ​
| Class | Description |
|---|---|
| SourceLoadErrorEvent | - |
Interfaces ​
| Interface | Description |
|---|---|
| FeaturesClickEvent | - |
| FeaturesHoverEvent | - |
| LayerCreationErrorEvent | - |
| LayerGeojsonWithData | - |
| LayerGeojsonWithUrl | - |
| LayerLoadingErrorEvent | - |
| MapClickEvent | - |
| MapContext | A map context, containing layers and a view. |
| MapContextBaseLayer | - |
| MapContextDiff | Describes a delta between two contexts, in order to be applied to an existing map. |
| MapContextLayerChanged | Describes a layer that was changed: both states before and after change are included |
| MapContextLayerGeotiff | - |
| MapContextLayerMapLibreStyle | - |
| MapContextLayerPositioned | Associates a position to a layer; the position is the index of the layer in the layers array |
| MapContextLayerReordered | Describes a layer being moved to a different position |
| MapContextLayerVector | - |
| MapContextLayerWms | - |
| MapContextLayerWmts | - |
| MapContextLayerXyz | - |
| MapEventsByType | - |
| MapExtentChangeEvent | - |
| MapLayerDataInfo | - |
| MapLayerStateChangeEvent | - |
| MapStateChangeEvent | - |
| MapViewStateChangeEvent | - |
| ResolvedMapState | Describes 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. |
| ResolvedMapViewState | Describes the actual view state of a map |
| ViewByExtent | - |
| ViewByGeometry | - |
| ViewByZoomAndCenter | - |
Type Aliases ​
| Type Alias | Description |
|---|---|
| Coordinate | - |
| Extent | Array components are respectively: minX, minY, maxX, maxY |
| FeaturesByLayerIndex | - |
| LayerDimensionValueRange | - |
| LayerDimensionValueSingle | - |
| LayerGeojson | - |
| MapContextLayer | A layer that can be used in a map context. |
| MapContextLayerGeojson | - |
| MapContextLayerOgcApi | - |
| MapContextLayerWfs | - |
| MapContextView | A 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 ​
| Variable | Description |
|---|---|
| defaultHighlightStyle | - |
| defaultStyle | - |
| FeaturesClickEventType | - |
| FeaturesHoverEventType | - |
| LayerCreationErrorEventType | - |
| LayerLoadingErrorEventType | - |
| MapClickEventType | - |
| MapExtentChangeEventType | DEPRECATED Use the MapViewStateChangeEvent instead |
| MapLayerStateChangeEventType | - |
| MapStateChangeEventType | - |
| MapViewStateChangeEventType | - |
| SourceLoadErrorType | DEPRECATED Use the MapLayerStateChangeEvent and LayerLoadingErrorEvent instead |
Functions ​
| Function | Description |
|---|---|
| addLayerToContext | Adds a layer to the context at a specific position or at the end if no position is specified. |
| changeLayerPositionInContext | Changes the position of a layer in the context. |
| computeMapContextDiff | The following logic is produced by identifying layers in both context and determining whether they have been added, removed, changed or reordered. |
| createViewFromLayer | Creates 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 | - |
| removeLayerFromContext | Removes a layer from the context. |
| removeSearchParams | Removes the given search params from the URL completely; this is case-insensitive |
| replaceLayerInContext | Replaces a layer in the context with a new layer. |
| updateLayer | Applies 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. |
| updateLayerInContext | Updates an existing layer in the context by applying partial changes. |