@xtramaps/web-map-openlayers
v1.1.0
Published
Framework-agnostic core logic for the OpenLayers web map component: projection setup, initial-view computation, and dynamic view/source switching when the active TileMatrixSet changes. Migrated from `ogcapi-html`'s `OpenLayers` component onto current `ol`
Readme
@xtramaps/web-map-openlayers
Framework-agnostic core logic for the OpenLayers web map component: projection setup, initial-view computation, and dynamic view/source switching when the active TileMatrixSet changes. Migrated from ogcapi-html's OpenLayers component onto current ol (10.8.0).
Install
npm install @xtramaps/web-map-openlayersRequires ol (10.8.0 exactly — pinned by rlayers's own peer dependency) as a peer dependency.
Usage
import { setupProjections, computeInitialView } from "@xtramaps/web-map-openlayers";
// register EPSG:25832/25833/3395 with ol - call once at module load, like the source did
setupProjections();
const initial = computeInitialView({
effectiveStyleUrl: styleUrl,
styleConfig,
tileMatrixSets,
currentTileMatrixSet,
bounds,
});Exports
setupProjections()- registers the custom EPSG:25832/25833/3395 projections used by ldproxy's TileMatrixSetscomputeInitialView()- computes the initial{center, zoom}view from a style, a TileMatrixSet, or bounds (in that precedence order)getRasterBackgroundAndAttributions()- derives a raster background URL/id and combined attribution string from a stylesetDynamicView()/setDynamicSource()- imperative helpers that swap anolmap's view or a layer's source when the active TileMatrixSet changes
License
MIT
