Lifecycle entry point of the module. It only logs.
It subscribes to nothing: the zoomend and style.load listeners are attached later, once
a layer's labels are prepared, and the loader drives labels by direct calls. The labels
capability calls it when it mounts; an integrator has no need to.
Optionaloptions: Record<string, unknown>
Ignored.
Rebuilds a layer's labels from its declared label configuration, if it has one.
Called by the loader as a layer comes up, and again on a style change. A layer's declared
configuration is the label object of its current style, else — the style carrying none,
or its file being missing — the labels block of its definition. The layer's label state
is purged first, so a layer that declares neither, or declares enabled: false, ends up
with none — labels an inline LabelsApi.enableLabels call had set included. This is
not the way to enable labels on such a layer: use enableLabels() with an inline config.
Layer to initialise.
Prepares a layer's labels — from its declared configuration, else from an inline one — and shows them unless told otherwise.
It returns a promise — await it. A labelConfig.styleFile rejects it: label style files
are obsolete, the label object carries the look.
Labels set up from an inline configuration are switched on and off by your own calls to
this method and LabelsApi.disableLabels: LabelsApi.toggleLabels and the
layer manager's labels button act only on a layer whose style or definition declares
labels. Hiding the layer — the layer manager's visibility toggle, GeoJSON.hideLayer(), a
theme — turns them off as disableLabels() does, and showing it again does not bring them
back: call enableLabels() again.
Layer to label.
OptionallabelConfig: LabelUserConfig
On a layer that DECLARES no label configuration — neither its style's
label object nor its definition's labels block — the whole configuration, which then
requires enabled: true and labelId (the feature property displayed). On a layer that
declares one, the declaration wins, and a declared enabled: false disables the labels
whatever is passed here; only labelId (when the declaration names no field) and
minZoom/maxZoom (together, when the current style sets no labelScale) are still
read. See LabelUserConfig.
OptionalshowImmediately: boolean
Show the labels once prepared; they render only while the layer
is visible. Defaults to true. A declared visibleByDefault takes precedence over it,
and a definition's labels block that omits it counts as visibleByDefault: false.
// A layer whose style or definition declares its labels: nothing else to pass
await GeoLeaf.Labels.enableLabels("poi_restaurants");
// A layer that declares none: the inline configuration, shown at once
// (labels render only while the layer is visible)
await GeoLeaf.Labels.enableLabels("poi_hotels", { enabled: true, labelId: "name" });
// ...and turned off again. toggleLabels() would change nothing on this layer.
GeoLeaf.Labels.disableLabels("poi_hotels");
Turns labels off for a layer and removes the rendered ones.
The prepared configuration is kept. On a layer that declares its labels,
LabelsApi.toggleLabels brings them back without re-supplying it; labels set up
from an inline configuration come back only through another enableLabels() call.
Layer whose labels are removed.
Flips a layer's labels and reports the state it settled on.
Acts only on a layer whose declared configuration — its style's label object, else its
definition's labels block — enables labels, and whose labels are prepared; for any other
it returns false and changes nothing. Labels set up from an inline enableLabels()
configuration are not among them: drive those with disableLabels() / enableLabels().
Layer to toggle.
true when labels are enabled after the call.
Whether a layer's labels are prepared — by the loader, or by an enableLabels() call.
Distinct from LabelsApi.areLabelsEnabled: prepared labels can be off. The layer manager's labels button does not read it: it reads the layer's declared configuration.
Layer to inspect.
true when the module holds label state for the layer.
Rebuilds a layer's labels against its current data.
Needed after the underlying features changed — enabling alone does not re-read them. It also re-reads the font the map's style serves: the capability calls it for every labelled layer when a basemap switch replaces the style.
Layer to rebuild.
Public + internal surface of the
Labelssingleton. Used to type thethisreceiver /selfparameters inlabels.tsand theLabels | nulllite stub.