Creates and mounts the map inside the given container. Must be called exactly once before any other method.
Map creation options.
Returns true after init() has completed successfully.
Methods that depend on a live map instance should guard on this flag.
Destroys the map instance and releases all associated resources.
After destroy(), no other methods may be called.
Sets the map center and zoom level without animation.
New geographic center.
New zoom level.
Returns the current geographic center of the map viewport.
Returns the current zoom level.
Sets the zoom level without changing the center.
New zoom level.
Pans the map to the given center without changing the zoom level.
MapLibre uses easeTo() without zoom change.
Target geographic center.
Smoothly animates the viewport to the target center and zoom level.
Target geographic center.
Optionalzoom: numberTarget zoom level (optional — keeps current zoom when omitted).
Adjusts the viewport to fit the given bounding box.
Geographic area to fit.
Optionaloptions: { padding?: GeoLeafPoint; animate?: boolean }Optional padding in screen pixels around the bounds.
Returns the current viewport as a geographic bounding box.
Subscribes to a map event.
The handler receives an engine-specific event object (unknown).
Adapters normalise geographic coordinates to GeoLeafLatLng within
the event object where applicable.
Event type token.
Callback invoked on each occurrence.
Unsubscribes a previously registered event handler. Silently does nothing if the handler was not registered.
Event type token.
The exact function reference passed to on().
Subscribes to a map event for a single occurrence, then auto-unsubscribes.
Event type token.
Callback invoked on the first occurrence.
Creates a GeoJSON layer from raw GeoJSON data and adds it to the map.
The adapter stores the layer internally keyed by id. Use removeLayer(),
setLayerVisibility(), updateLayerData(), and setLayerStyle() to
manage it afterwards.
Unique layer identifier.
GeoJSON data (FeatureCollection, Feature, or Geometry).
Validated by the adapter at runtime.
Optionaloptions: GeoLeafLayerOptionsOptional layer display options.
Removes the layer identified by id from the map and disposes it.
The layer identifier used in addGeoJSONLayer().
Returns true if a layer with the given id is currently managed by the adapter.
Layer identifier to check.
Shows a previously hidden layer.
Layer identifier.
Hides a layer without removing it from the adapter's internal registry.
Layer identifier.
Replaces the GeoJSON data of an existing layer.
Internally clears the current features and adds the new data. The layer keeps its id, options, and style.
Layer identifier.
New GeoJSON data (FeatureCollection, Feature, or Geometry).
OptionalsetSets feature-state on a layer's source feature, targeted by its promoted
id — reactive paint (e.g. POI sync badge, hover/selection halo) without a
source data rebuild. Maps to map.setFeatureState(). The source must
declare promoteId for a string id to resolve.
Layer identifier (resolves to the backing source).
Promoted feature id to target.
Feature-state key/values to set.
Applies a style to an existing GeoJSON layer.
Layer identifier.
Vector fill and stroke style options.
Applies a filter expression to an existing layer.
Maps to map.setFilter() with a MapLibre expression
array (e.g. ["==", ["get", "type"], "park"]).
Layer identifier.
Engine-specific filter expression (unknown).
Pass null to clear the filter.
Updates the zoom range of an existing layer, on every one of its sub-layers.
Maps to map.setLayerZoomRange(). Needed because a scale bound converts to a zoom
level THROUGH THE LATITUDE: the same 1:X sits at different zooms in Cayenne and in
Tromsø. A range posted at load time therefore drifts as the user pans north or
south, and has to be re-pushed — but never on zoom, which does not affect the
conversion.
Layer identifier.
Lowest zoom at which the layer renders, or null to clear.
Highest zoom at which the layer renders, or null to clear.
Creates a marker at the given position and adds it to the map.
The adapter stores the marker internally keyed by id.
Unique marker identifier.
Geographic position of the marker anchor.
Optionaloptions: GeoLeafMarkerOptionsMarker display options.
Removes a marker from the map and releases its resources.
The marker identifier used in createMarker().
Updates the geographic position of an existing marker.
The marker identifier used in createMarker().
New geographic position.
OptionalgetReturns a handle on an existing marker, or null when no marker carries that id.
The id-based surface above covers the common cases; this exists for the two things
it cannot express — reading a marker's position after the user dragged it, and
subscribing to its own events. Prefer updateMarkerPosition() and the map-level
on() whenever they suffice.
Optional: an adapter whose engine has no per-marker event model may omit it, and
callers must handle undefined as they do for the other optional members.
The marker identifier used in createMarker().
Creates a cluster group for grouping markers at low zoom levels.
The adapter stores the cluster group internally keyed by id.
Unique cluster group identifier.
Optionaloptions: Record<string, unknown>Clustering options (engine-specific, typed unknown).
Each adapter validates the concrete options internally.
Creates a popup with the given content.
Returns an opaque handle (unknown) to pass to openPopup() /
closePopup(). The popup is not opened automatically — call openPopup()
after creation.
HTML string or DOM element to display inside the popup.
Optionaloptions: GeoLeafPopupOptionsOpens (displays) a popup on the map.
The opaque handle returned by createPopup().
Optionalposition: GeoLeafLatLngGeographic position at which to anchor the popup. When omitted, the popup opens at its previously stored position.
Closes a popup without destroying it.
When popup is omitted, all open popups are closed.
Optionalpopup: unknownThe opaque handle returned by createPopup(). Optional.
Adds a native control object to the map at the specified corner.
Returns a GeoLeafControl handle that can be passed to removeControl().
Native control object (engine-specific, typed unknown).
Map corner where the control is rendered.
Removes a control from the map.
The GeoLeafControl handle returned by addControl().
Projects a geographic coordinate to a pixel point relative to the map container's top-left corner.
Geographic coordinate to project.
Unprojects a pixel point (relative to the map container) back to a geographic coordinate.
Pixel coordinate to unproject.
Returns the map's root DOM container element. Useful for positioning custom overlays or reading container dimensions.
OptionalgetReturns the underlying native map instance (MapLibre GL Map object).
Intended for low-level integrations that cannot be expressed through the standard adapter interface. Use sparingly — direct access bypasses the adapter contract and may break on engine upgrades.
Returns unknown to avoid importing engine-specific types in this file.
OptionalbuildBuilds a transformStyle callback (setStyle option, depuis MapLibre v5) that
preserves the adapter-owned sources and layers across a basemap style swap,
so they survive natively rather than being torn down and re-injected.
Returns null when nothing is owned yet.
Called by the basemap registry immediately before setStyle(). The return
type is intentionally opaque here to keep the contract engine-agnostic.
OptionalreregisterRe-registers runtime images (e.g. POI sprite icons) wiped by
map.setStyle(). Sources and layers are preserved by the style transform;
images are not part of the style spec and must be re-added after the swap.
Called by the basemap registry inside the post-swap style.load handler.
OptionaladdAdds a native vector-tile source and its styled sub-layers (fill / line /
circle / fill-extrusion / casing), registering them in the adapter's layer
registry. Returns the created sub-layer ids (for interaction binding and layer
bookkeeping). Engine-specific (vector tiles are a MapLibre-native concept) — a
non-MapLibre adapter may omit it. Socle B.1: the vector-tiles capability
resolves config/style and delegates all rendering here.
OptionalupdateUpdates the paint of an existing vector-tile layer's sub-layers from raw GeoLeaf style objects (normalised by the adapter). Companion to addVectorTileLayer.
Engine-agnostic map adapter interface.
MaplibreAdapterimplements this interface. All GeoLeaf modules interact with the map exclusively through this interface — nomaplibregl.*references outside of the adapter implementation.Id-based management: Layers, markers, and cluster groups are managed by string identifiers. The adapter stores native engine objects internally — callers never interact with MapLibre overlays directly.
Opaque handles:
createPopup()returnsunknownbecause the underlying type differs between engines. Callers must treat popup handles as opaque and pass them back toopenPopup()/closePopup().Example