/** * OpenLayers adapter — grafts onto a host-owned `ol/Map`. Per-overlay style * functions read the same feature render-props as the MapLibre adapter, so the * engines render identically. Glyphs use `ol/style/Icon` (sprite or data-URI); * text boxes use OL's native `backgroundFill`/`backgroundStroke`. * * The manifest (`layers`) and the hit-testable set (`hitOverlays`) are supplied * by the consumer; this adapter knows no domain type. */ import type { FeatureCollection } from "geojson"; import OlMap from "ol/Map.js"; import type { AdapterOptions, HighlightStyle, KeyEvent, LatLng, LngLatBounds, MapAdapter, MarkerWidget, PointerEvent, ProjectionSpec, SnapshotOptions, SymbolSprites, ToolbarItem, ToolbarOptions, TooltipStyle, WidgetEdit } from "./index.js"; /** Batteries-included host map (headless hosts pass their own `map` instead). */ export declare function createOpenLayersMap(opts: { container: HTMLElement | string; center: [number, number]; zoom: number; }): OlMap; export declare class OpenLayersAdapter implements MapAdapter { /** OpenLayers composites onto `` layers → snapshot is supported. */ protected readonly snapshotSupported = true; private readonly map; private readonly opts; private readonly kindOf; /** overlay id → manifest z-index (higher = drawn on top), for hit priority. */ private readonly zOf; private readonly sources; private readonly layers; private readonly layerOverlay; private readonly format; private readonly iconCache; private sprites; private dragPan; private dblClickZoom; private readyPromise; private tooltipStyle; private olKeys; private viewKey; private domPointerUp; private windowBlur; private blurListener; /** Press state captured at `down`, used to emit a `click` immediately on release — OL's own * `singleclick` is ~250 ms delayed and a quick second click becomes a `dblclick`, so deselect * felt like it needed several clicks. */ private pressHit; private pressLngLat; private pressX; private pressY; private pressDown; private viewportPointerDown; private keyCleanup; private viewportDblclick; private viewportContext; private toolbarEl; private tooltipEl; private dragging; private locked; private panOn; private dblOn; private widgets; private pointerCb; /** Coord formatter, mirrored from {@link setCoordFormat} so sprites format `coord` leaves like cards. */ private coordFmt; /** Source/layer for `static`-widget sprites (lazy; mapped to {@link WSPRITE_HIT_OVERLAY} for hits). */ private spriteSource; private spriteLayer; /** Monotonic token so a superseded async sprite update never clobbers a newer `setWidgets`. */ private spriteToken; /** Widget ids with a live sprite (for cache eviction on `destroy`). */ private readonly spriteIds; /** Raw EPSG:4326 data per overlay, kept so a projection swap can re-read (reproject) it. */ private readonly lastData; /** The non-interactive frame layer (see {@link highlightArea}); its last extent + style, so a * projection swap redraws it into the new view. */ private highlightLayer; private highlightExtent; private highlightStyleOpts; /** Last {@link viewArea} request, re-applied once an async projection swap settles. */ private lastFit; /** True while a `{kind:"proj4"}` view swap is loading proj4 (defers `viewArea` until it lands). */ private projPending; constructor(opts: { map: OlMap; } & AdapterOptions); registerSymbols(sprites: SymbolSprites): Promise; ready(): Promise; /** The view's CURRENT projection — the single source of truth for every lon/lat ↔ map * transform below, so a {@link setProjection} swap reprojects everything consistently. */ private viewProj; setOverlay(id: string, data: FeatureCollection): void; /** Read `data` (EPSG:4326) into overlay `id`'s source, reprojected to the view's projection. */ private loadInto; setOverlayVisible(id: string, visible: boolean): void; addToolbar(items: ToolbarItem[], options?: ToolbarOptions): HTMLElement; setActiveTool(id: string | null): void; /** Capture the map as PNG, then apply `opts.target` (download/clipboard/none). The * capture promise is handed to `deliverSnapshot` *pending* so a clipboard write fires * synchronously within the click (gesture-safe). */ snapshot(opts?: SnapshotOptions): Promise; /** * Compose every visible layer canvas onto one target canvas inside a * `rendercomplete` frame (OpenLayers' official "export map" pattern). `scale` * defaults to the device-pixel-ratio (OL already renders at that density); * the target canvas is `getSize() × scale` and each layer's CSS transform is * pre-multiplied by `scale`, so `low` stays at CSS resolution and `medium`/`high` * supersample (best-effort). */ private capture; /** Hide the given overlay ids' layers; returns a function that restores their * visibility. Used to drop editing chrome from a snapshot. */ private hideOverlays; getCenter(): LatLng; getViewSpan(): number; getBounds(): LngLatBounds; getZoom(): number; getContainer(): HTMLElement; fitBounds(bbox: LngLatBounds, opts?: { padding?: number; }): void; setProjection(projection: ProjectionSpec): void; /** Register a proj4 def, make it available to OL, and swap the view onto it. */ private applyProj4; /** Rebuild the view onto `projection` (keeping the center as lon/lat + zoom), then re-read every * overlay + the highlight so their geometries reproject. */ private swapProjection; viewArea(extent: LngLatBounds, opts?: { padding?: number; duration?: number; }): void; /** Project the (densified, dateline-aware) area ring into the view projection and fit its bounding * box — so the framing follows the projection's curvature and never zooms out across the dateline. */ private applyFit; highlightArea(extent: LngLatBounds | null, style?: HighlightStyle): void; /** (Re)draw the frame polygon (densified, reprojected to the view) into the highlight layer. */ private drawHighlight; /** The frame's own VectorLayer, inserted directly BELOW the first drawing overlay (so it sits * above the basemap, below the overlays). Non-hittable: it is absent from `layerOverlay`. */ private ensureHighlightLayer; project(p: LatLng): [number, number] | null; unproject(px: [number, number]): LatLng | null; onViewChange(cb: () => void): void; setPanEnabled(enabled: boolean): void; setDoubleClickZoom(enabled: boolean): void; setInteractive(enabled: boolean): void; setCursor(cursor: string): void; setTooltip(text: string | null, at: LatLng, style?: TooltipStyle): void; onPointer(cb: (ev: PointerEvent) => void): void; onKey(cb: (ev: KeyEvent) => void): void; onBlur(cb: () => void): void; private widgetLayer; setWidgets(widgets: MarkerWidget[]): void; onWidgetEdit(cb: (e: WidgetEdit) => void): void; onWidgetDelete(cb: (e: { id: string; }) => void): void; onWidgetAction(cb: (e: { id: string; event: string; }) => void): void; setCoordFormat(fn: (ll: LatLng) => string): void; /** Add the sprite source + vector layer once (lazy). Mapped to {@link WSPRITE_HIT_OVERLAY} so its * features hit-test like canvas call-outs; given a top z so they hit even if the consumer's manifest * has no `text-boxes` layer (else its `z` would be -1 and never win the hit priority). */ private ensureSpriteLayer; /** * Rasterize each `static` widget to an `Icon` and push them as point features (props * `{ featureId, labelId }`) into the sprite layer. Async (glyph rasterization) and token-guarded so * a newer call wins. */ private updateSprites; destroy(): void; private hitAt; private icon; private dataIcon; private styleFor; } //# sourceMappingURL=openlayers.d.ts.map