GeoLeaf Core API - v3.19.0
    Preparing search index...

    MapLibre GL JS adapter — implements IMapAdapter. One instance per map.

    Implements

    Index
    • Whether error is MapLibre's GPUInitializationError — thrown when the browser cannot create the WebGL2 context MapLibre 6 requires.

      The class is matched when the MapLibre global exposes it; the name is the fallback for a build or a test double that does not.

      Parameters

      • error: unknown

        Whatever the map construction threw.

      Returns boolean

      true for a WebGL2 context failure.

    • Adjusts the viewport to fit the given bounding box.

      Parameters

      • bounds: GeoLeafBounds

        Geographic area to fit.

      • Optionaloptions: {
            padding?: GeoLeafPoint | Record<string, number>;
            animate?: boolean;
            maxZoom?: number;
        }

        padding: room kept around the bounds, in screen pixels. animate: false to jump. maxZoom: a ceiling on the zoom the framing may reach — a small area is then shown from further away instead of filling the viewport.

      Returns void

    • 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.

      Parameters

      • event: MapEvent

        Event type token.

      • handler: (e: unknown) => void

        Callback invoked on each occurrence.

      Returns void

    • Applies a partial update to an existing source, and reports whether it took it.

      Returns false — never throws, never falls back on its own — whenever the live source cannot address features by id. The caller owns the fallback because the caller owns the whole collection; see the contract's note on why that placement is what makes the fallback observable.

      ⚠️ The promise from updateData is dropped, exactly as setData's already is (it is Promise<void> too in MapLibre 6). The catch is a guard against a FUTURE version rejecting: today _dispatchWorkerUpdate swallows everything into an ErrorEvent, so this handler cannot fire. Said plainly here so the next reader does not mistake it for a covered case.

      Parameters

      Returns boolean

    • Sets feature-state on a registered source's feature, targeted by its promoted id. Used for reactive paint (POI sync badge, hover/selection halo) without rebuilding the source data. No-op if the source is gone. The source must declare promoteId for a string id to resolve.

      Parameters

      • id: string
      • featureId: string | number
      • state: Record<string, unknown>

      Returns void

    • Applies owner's filter expression to a registered layer's sub-layers, AND-ed with the other owners' filters (_composeFilterSlots). For cluster groups, filters the unclustered-point layer specifically. Pass null to clear owner's filter — the other owners' stay.

      🛑 The caller's filter is COMPOSED with the filter each sub-layer was BUILT with, never substituted for it. setFilter replaces a layer's filter wholesale, and the builders put there predicates the drawing depends on: a typed sub-layer's geometry guard, a clustered layer's point_count predicates (the unclustered circle, the bubbles, their count), an icon sub-layer's symbolId. A plain assignment stripped them for as long as a filter was active — a clustered layer drew its centroids as points and its points as bubbles — and clearing it stripped them for good. The built filter is read from the engine the first time a caller filters the sub-layer: until then, only the builders have written it — a filter written through getNativeMap() before that is taken for the built one, one written after is replaced.

      ⚠️ A bubble carries none of its points' properties — only cluster, cluster_id, point_count and point_count_abbreviated. A filter that REQUIRES a property value therefore hides every bubble; one that passes a feature lacking the property — such as hideFeatures' exclusion — keeps them. The core's own filter re-feeds a clustered layer instead (geojson-filter.ts).

      Parameters

      • id: string

        The layer.

      • filter: unknown

        A MapLibre filter expression, or null to clear owner's.

      • owner: string = "filter"

        Whose filter it is: "filter" (the default — the panel's and the visible subset's) or "hidden" (GeoLeaf.Layers.hideFeatures).

      Returns void

    • Sets the zoom range on every sub-layer of a registered layer.

      Iterates getSubLayerIds rather than subLayerTypes: only the former carries the cluster sub-layers (they are registered via customSubLayerIds), and a cluster left out of the range would keep rendering outside it.

      Parameters

      • id: string
      • minZoom: number | null
      • maxZoom: number | null

      Returns void

    • Re-reads the container size and resizes the WebGL drawing buffer.

      The third of the three gestures resize needs: declaring it on the contract and calling it from reattach() is not enough — without an implementation the call lands on undefined and, the member being optional, does so in SILENCE.

      Returns void

    • Builds a transformStyle callback that preserves the GeoLeaf-owned sources and layers across a map.setStyle() basemap swap, so they survive natively instead of being torn down and re-injected from JS (the former geoleaf:style:rebuild dance — audit redundancy #1).

      What GeoLeaf owns — the layer registry (GeoJSON sub-layers + sources), the POI cluster ids, the sentinel z-anchor, and what code outside the adapter declared through declareOwnedStyleIds — is read when MapLibre RUNS the callback, not here. For a style given by URL that is once the style has downloaded, and the layers created in between must be carried too.

      🛑 Never null, even with nothing owned and no credit declared: an empty registry NOW says nothing about the registry when the style lands. Returning null handed the caller a plain setStyle(), which diffs the arriving style all the same and erased every layer created during the download — the boot of a vector default basemap, whose data layers land exactly then.

      Called by the basemap registry immediately before setStyle().

      Parameters

      • options: StyleTransformOptions = {}

        The incoming basemap's declared credit, set on its sources that carry none — from the very first style load.

      Returns StyleTransform

      The transform.

    • Puts back the runtime images a map.setStyle() may have left behind: the hatch patterns, then the POI sprite icons.

      The transformStyle merge (see buildStyleChangeTransform) carries sources and layers. Images added via map.addImage() are not part of the style spec, and what becomes of them depends on the engine: a style change it can DIFF keeps them, one it cannot — it then rebuilds the style from scratch — starts with an empty image store. Both steps only add what is missing, so they cost nothing on the first path.

      The sprite step is skipped when no profile sprite is present, so sprite-less profiles pay nothing and log no warning; the hatch step runs regardless.

      Called by the basemap registry inside the post-swap style.load handler.

      Returns void