Skip to content

📦 openlayers ​

This package provides utilities to create and manage OpenLayers maps using the declarative Map Context model from @geospatial-sdk/core.

Installation ​

sh
npm install @geospatial-sdk/openlayers

Usage ​

typescript
import { createMapFromContext } from "@geospatial-sdk/openlayers";
import type { MapContext } from "@geospatial-sdk/core";

const mapContext: MapContext = {
  layers: [
    {
      type: "xyz",
      url: "https://tile.openstreetmap.org/{z}/{x}/{y}.png",
    },
  ],
  view: {
    center: [6, 48.5],
    zoom: 5,
  },
};

const map = await createMapFromContext(
  mapContext,
  document.getElementById("map"),
);

Functions ​

FunctionDescription
applyContextDiffToMapApply a context diff to an OpenLayers map
createMapFromContextCreate an OpenLayers map from a context; optionally specify a target (root element) for the map
listen-
readMapViewStateReads the current view state of the map.
resetMapFromContextResets an OpenLayers map from a context; existing content will be cleared