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

    Interface LabelButtonManagerApi

    The 🏷️ toggle buttons the layer manager injects next to each labelled layer.

    Mounted on the global as GeoLeaf._LabelButtonManager. ⚠️ There is no sync() member, despite what docs/labels/LABEL_BUTTON_MANAGER.md documents: the surface is LabelButtonManagerApi.syncImmediate plus the private _doSync, and every real caller uses the former. The phantom went unnoticed because the global declares _LabelButtonManager?: unknown, so no call through it was type-checked — typed since.

    interface LabelButtonManagerApi {
        createButton(
            layerId: string,
            controlsContainer: HTMLElement,
        ): HTMLElement | null;
        _doSync(layerId: string): void;
        _getState(layerId: string): LabelButtonSyncState;
        _applyState(button: HTMLButtonElement, state: LabelButtonSyncState): void;
        syncImmediate(layerId: string): void;
        removeButtons(): void;
    }
    Index
    • Builds the toggle button for a layer and attaches it to the controls container.

      Called by the layer manager on first render of a layer item.

      Parameters

      • layerId: string

        Layer the button drives.

      • controlsContainer: HTMLElement

        Element the button is appended to.

      Returns HTMLElement | null

      The button — the container's existing one if it has one — or null when an argument is missing. It is built for every layer, disabled; syncImmediate() enables it while the layer declares labels and is visible.

      // Called by Layer Manager during first render
      const button = GeoLeaf._LabelButtonManager?.createButton("poi-restaurants", controlsContainer);
    • Re-reads a layer's state and repaints its button, synchronously.

      ⚠️ This said "bypassing the debounce" and named _doSync as "the debounced counterpart" until 04/09/2026. There is no debounce — this module holds no timer and no pending-sync state, and _doSync repaints on the spot. The claim came from the shipped docs/labels/ page, which described a 300 ms timer and a _syncTimeouts map that were never in the code; both are corrected.

      ⚠️ Internal. The public route is GeoLeaf.Labels.syncLayerControl(), which delegates here — prefer it, and see the migration table under docs/reference/consumers/.

      Parameters

      • layerId: string

        Layer whose button is repainted.

      Returns void

      // Called after a layer visibility toggle.
      GeoLeaf.Labels.syncLayerControl("poi-restaurants");
    • Removes every injected button and releases their listeners.

      ⚠️ Not cosmetic: each button carries two listeners that nothing else releases, so a destroy without this leaves clickable toggles wired to a torn-down singleton.

      Returns void