/**
* Leaflet adapter — grafts onto a host-owned `L.Map`. Leaflet is lat/lng-native
* (no reprojection). Reads the same feature render-props as the MapLibre /
* OpenLayers adapters so all three render identically.
*
* Per-overlay z-order uses one Leaflet **pane** per {@link LayerSpec} (increasing
* `zIndex`); rotatable handle/symbol glyphs use `L.divIcon` + a CSS
* `transform: rotate()` (Leaflet markers don't rotate natively). Leaflet has no
* `queryRenderedFeatures`, so hit-testing is done GEOMETRICALLY at pointer time
* ({@link LeafletAdapter.hitAt}): each rendered feature is projected to container
* pixels and the topmost one within a ~5px tolerance wins — parity with the MapLibre
* (5px query box) / OpenLayers (`hitTolerance:5`) adapters, and independent of any
* prior hover so a freshly drawn/re-rendered feature is immediately selectable.
* The drag-vs-pan conflict is solved exactly like the
* OpenLayers adapter: a capture-phase `pointerdown` on the container
* `stopPropagation()`s draggable presses so Leaflet's own drag never starts a pan.
*
* 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 * as L from "leaflet";
import type { AdapterOptions, HighlightStyle, KeyEvent, LatLng, LngLatBounds, MapAdapter, MarkerWidget, PointerEvent, ProjectionSpec, SymbolSprites, ToolbarItem, ToolbarOptions, TooltipStyle, WidgetEdit } from "./index.js";
/** Batteries-included host map (headless hosts pass their own `map` instead). */
export declare function createLeafletMap(opts: {
container: HTMLElement | string;
center: [number, number];
zoom: number;
}): L.Map;
export declare class LeafletAdapter implements MapAdapter {
/** Leaflet has no single exportable canvas (tiles are
, overlays SVG/DOM). */
protected readonly snapshotSupported = false;
private readonly map;
private readonly opts;
private readonly kindOf;
private readonly groups;
private readonly paneNames;
private sprites;
private readyPromise;
private dragging;
private locked;
private panOn;
private dblOn;
private tooltipStyle;
private tooltipEl;
private toolbarEl;
private cb;
private domDown;
private domUp;
private domMove;
private windowBlur;
private blurListener;
/** Hit captured at `down`, reused for that press's `click` (atomic press — see onPointer). */
private pressHit;
private keyCleanup;
private lastDownT;
private lastDownX;
private lastDownY;
/** After a (manually-detected) double-click, Leaflet still fires a trailing `click` for that 2nd
* press. Unlike MapLibre/OL — where `dblclick` is the LAST event of the gesture — that stray click
* would land AFTER the consumer's commit→select (e.g. finishing a drawn front), carrying an empty
* hit and deselecting it. This flag swallows exactly that one click. */
private suppressClick;
/** Whether the pointer moved past a small threshold since the press started. Leaflet fires a native
* `click` after a drag (the map didn't pan, so it doesn't suppress it) — but MapLibre/OL only emit
* a click for a STATIONARY press (`!moved`). Without this, finishing a drag-drawn shape (the
* consumer commits+selects on `up`) is immediately undone by the trailing empty-hit click. */
private moved;
private viewHandler;
private widgets;
/** Coord formatter, mirrored from {@link setCoordFormat} so sprites format `coord` leaves like cards. */
private coordFmt;
/** Group of `static`-widget sprite markers (lazy); hit-tested geometrically as {@link WSPRITE_HIT_OVERLAY}. */
private spriteGroup;
/** 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;
/** The non-interactive {@link highlightArea} frame + whether its dedicated pane exists. */
private highlightPoly;
private highlightPaneReady;
constructor(opts: {
map: L.Map;
} & AdapterOptions);
ready(): Promise;
registerSymbols(sprites: SymbolSprites): Promise;
setOverlay(id: string, data: FeatureCollection): void;
setOverlayVisible(id: string, visible: boolean): void;
/** Not supported yet — see {@link LEAFLET_SNAPSHOT_UNSUPPORTED}. (async ⇒ rejects.) */
snapshot(): Promise;
setTooltip(text: string | null, at: LatLng, style?: TooltipStyle): void;
addToolbar(items: ToolbarItem[], options?: ToolbarOptions): HTMLElement;
setActiveTool(id: string | null): void;
getCenter(): LatLng;
getViewSpan(): number;
getBounds(): LngLatBounds;
getZoom(): number;
getContainer(): HTMLElement;
fitBounds(bbox: LngLatBounds, opts?: {
padding?: number;
}): void;
setProjection(projection: ProjectionSpec): void;
viewArea(extent: LngLatBounds, opts?: {
padding?: number;
duration?: number;
}): void;
highlightArea(extent: LngLatBounds | null, style?: HighlightStyle): void;
/** A dedicated pane for the frame, ABOVE the tiles and BELOW the drawing overlay panes
* (which start at zIndex 400); pointer-events off so it never intercepts clicks. */
private ensureHighlightPane;
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;
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;
/** Create the sprite pane + group once (lazy: only when a `static` widget appears). */
private ensureSpriteLayer;
/**
* Rasterize each `static` widget to an `
` divIcon marker (props `{ featureId, labelId }` on the
* marker's `feature`, so the geometric {@link hitAt} surfaces them as call-out hits). The markers are
* `interactive: false`: the press falls through to the map and is resolved geometrically, exactly
* like a canvas call-out — never the DOM-card `widget` path. Async + token-guarded.
*/
private updateSprites;
destroy(): void;
/**
* Resolve the feature under a container-pixel point GEOMETRICALLY, with a ~5px tolerance
* ({@link HIT_TOL}) — Leaflet's stand-in for `queryRenderedFeatures`. Scans every hittable
* overlay's live layers (skipping hidden panes + overlays excluded by `hitOverlays`), measures
* the screen-space distance from the point to each feature's surface (0 = inside/on it), and
* returns the TOPMOST (highest manifest z, then nearest) feature within tolerance. Independent
* of any prior hover, so a freshly drawn/re-rendered feature is hittable with no mouse move.
*/
private hitAt;
/** Screen-space distance (px) from `pt` to a rendered layer's surface — `0` when inside/on it,
* `null` when the layer carries no hittable geometry. Mirrors the geometry kinds Leaflet renders:
* polygon (inside-or-edge), polyline (nearest segment), circle (centre±radius), marker (its DOM
* box, so glyph/symbol/text-call-out sizes are honoured), and groups (nearest child). */
private surfaceDist;
private styleFor;
private pointLayer;
/** Build a rotatable glyph divIcon from a feature's `icon` (data-URI) or `symbol`
* (sprite, tinted by `symbolColor`). Returns undefined when neither is present. */
private glyphHtml;
private textIcon;
}
//# sourceMappingURL=leaflet.d.ts.map