LabelLayer
Defined in: labels/label-layer.ts:134
An HTML overlay of absolutely-positioned label elements. On each update it maps reference anchors through the view transform to screen pixels, culls to the viewport with collision resolution, and reconciles the DOM (reusing nodes by id). Geometry stays on the GPU; only the surviving labels are in the DOM.
The container should be positioned (e.g. position: relative) and overlay the
canvas; label nodes are position: absolute.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new LabelLayer(
container,text,className?,style?):LabelLayer
Defined in: labels/label-layer.ts:140
Parameters
Section titled “Parameters”container
Section titled “container”HTMLElement
(anchor) => string
className?
Section titled “className?”string
Optional class set on each label element, for styling the overlay (font, colour, halo).
style?
Section titled “style?”Optional inline CSS set on each label element, applied ONCE at creation — never on the per-transform update path. Applied as given: engine callers pass the default-merged result of resolveLabelStyle; omitted, elements inherit from the container as before.
Returns
Section titled “Returns”LabelLayer
Methods
Section titled “Methods”destroy()
Section titled “destroy()”destroy():
void
Defined in: labels/label-layer.ts:253
Returns
Section titled “Returns”void
setHover()
Section titled “setHover()”setHover(
anchor,restore,transform):void
Defined in: labels/label-layer.ts:234
Show anchor’s text (the label in full) in place of its trimmed twin while hovered (#496), or
clear it (null). restore is the text the label returns to on the next call. O(1): one node
lookup (a new node is made only when the label was not placed), no placement pass, so a hover
sweep costs the same per pointer move whatever number of labels is placed. The stored anchor also
applies on every later update.
Parameters
Section titled “Parameters”anchor
Section titled “anchor”LabelAnchor | null
restore
Section titled “restore”string
transform
Section titled “transform”Returns
Section titled “Returns”void
update()
Section titled “update()”update(
anchors,transform,viewport):void
Defined in: labels/label-layer.ts:187
Parameters
Section titled “Parameters”anchors
Section titled “anchors”readonly LabelAnchor[]
transform
Section titled “transform”viewport
Section titled “viewport”height
Section titled “height”number
number
Returns
Section titled “Returns”void