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.
Layer the button drives.
Element the button is appended to.
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.
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/.
Layer whose button is repainted.
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.
The 🏷️ toggle buttons the layer manager injects next to each labelled layer.
Mounted on the global as
GeoLeaf._LabelButtonManager. ⚠️ There is nosync()member, despite whatdocs/labels/LABEL_BUTTON_MANAGER.mddocuments: 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.