Skip to content

API reference / @zaes/tactical-graphics/maplibre / NativeLayerRenderer

Class: NativeLayerRenderer ​

Defined in: components/maplibre/native/NativeLayerRenderer.ts:278

Constructors ​

Constructor ​

ts
new NativeLayerRenderer(map, options?): NativeLayerRenderer;

Defined in: components/maplibre/native/NativeLayerRenderer.ts:375

Parameters ​

map ​

Map$1

options? ​

NativeLayerRendererOptions = {}

Returns ​

NativeLayerRenderer

Properties ​

lastFeatureCount ​

ts
lastFeatureCount: number = 0;

Defined in: components/maplibre/native/NativeLayerRenderer.ts:300

GeoJSON features uploaded on that realization.


lastRealizeBreakdown ​

ts
lastRealizeBreakdown: object;

Defined in: components/maplibre/native/NativeLayerRenderer.ts:309

Where the last realization's time went, in milliseconds.

Kept because "realize costs 26 ms" is not actionable and "22 of the 26 are in setData" is. Three numbers, taken from a clock that is already running.

bucket ​

ts
bucket: number;

paint ​

ts
paint: number;

upload ​

ts
upload: number;

lastRealizeMs ​

ts
lastRealizeMs: number = 0;

Defined in: components/maplibre/native/NativeLayerRenderer.ts:298

Milliseconds the last geometry realization took. The number the spike is for.


lastVisibleCount ​

ts
lastVisibleCount: number = 0;

Defined in: components/maplibre/native/NativeLayerRenderer.ts:311

How many graphics survived the cull on the last realization.


realizeCount ​

ts
realizeCount: number = 0;

Defined in: components/maplibre/native/NativeLayerRenderer.ts:302

How many times the geometry has been rebuilt since construction.

Accessors ​

count ​

Get Signature ​

ts
get count(): number;

Defined in: components/maplibre/native/NativeLayerRenderer.ts:532

Returns ​

number


selection ​

Get Signature ​

ts
get selection(): string | null;

Defined in: components/maplibre/native/NativeLayerRenderer.ts:749

The currently selected graphic's id, or null.

Returns ​

string | null

Methods ​

add() ​

ts
add(graphic): void;

Defined in: components/maplibre/native/NativeLayerRenderer.ts:467

Parameters ​

graphic ​

PaintedGraphic

Returns ​

void


centerHandleOf() ​

ts
centerHandleOf(graphic): number;

Defined in: components/maplibre/native/NativeLayerRenderer.ts:1133

Which of a graphic's handles is its center, or -1.

Found by position, not by index: the documented order for the point-anchored family is [edge, center], but a range fan emits one handle per band and the corridors emit one per turning point, so an index would be right for one family and wrong for the rest. A handle sitting on the base point is the center in every family that has one.

Parameters ​

graphic ​

PaintedGraphic

Returns ​

number


clear() ​

ts
clear(): void;

Defined in: components/maplibre/native/NativeLayerRenderer.ts:527

Returns ​

void


destroy() ​

ts
destroy(): void;

Defined in: components/maplibre/native/NativeLayerRenderer.ts:1199

Returns ​

void


find() ​

ts
find(id): PaintedGraphic | undefined;

Defined in: components/maplibre/native/NativeLayerRenderer.ts:1062

The graphic with this id, or undefined.

Parameters ​

id ​

string

Returns ​

PaintedGraphic | undefined


flush() ​

ts
flush(): void;

Defined in: components/maplibre/native/NativeLayerRenderer.ts:497

Runs any pending rebuild now. For a caller that cannot wait a microtask.

Returns ​

void


hitTest() ​

ts
hitTest(point, radiusPx?): PaintedGraphic | undefined;

Defined in: components/maplibre/native/NativeLayerRenderer.ts:1105

The graphic under a screen point, or undefined.

radiusPx widens the query into a box, because most of these symbols are line work: a one-pixel query against a two-pixel line asks the user to be more accurate than the symbol is wide.

Parameters ​

point ​
x ​

number

y ​

number

radiusPx? ​

number = 5

Returns ​

PaintedGraphic | undefined


hitTestHandle() ​

ts
hitTestHandle(point, radiusPx?): 
  | {
  graphic: PaintedGraphic;
  index: number;
}
  | undefined;

Defined in: components/maplibre/native/NativeLayerRenderer.ts:1143

The handle index under a screen point, or -1.

Queried ahead of the graphic body, because a handle sits on the graphic it belongs to and the body would otherwise always win.

Parameters ​

point ​
x ​

number

y ​

number

radiusPx? ​

number = 8

Returns ​

| { graphic: PaintedGraphic; index: number; } | undefined


realize() ​

ts
realize(): void;

Defined in: components/maplibre/native/NativeLayerRenderer.ts:543

Rebuilds every graphic's geometry at the current resolution and uploads it.

This is the whole of path B's per-zoom cost: run the paint functions, bucket the marks, reproject every coordinate to lon/lat, and hand MapLibre new GeoJSON. Timed end to end.

Returns ​

void


replace() ​

ts
replace(id, next): void;

Defined in: components/maplibre/native/NativeLayerRenderer.ts:1091

Swaps a graphic for a rebuilt version of itself, keeping its place in the draw order.

Order matters because the paint list is emitted in graphic order and MapLibre draws a source's features in the order they arrive: moving an edited graphic to the end would lift it above whatever it used to sit under.

Parameters ​

id ​

string

next ​

PaintedGraphic

Returns ​

void


select() ​

ts
select(id): void;

Defined in: components/maplibre/native/NativeLayerRenderer.ts:742

Shows the given graphic's handles, or none.

Separate from realize because selection changes far more often than geometry does — a click that only moves the selection has no reason to repaint 200 graphics.

Parameters ​

id ​

string | null

Returns ​

void


setHandleMode() ​

ts
setHandleMode(active, selectionScoped?): void;

Defined in: components/maplibre/native/NativeLayerRenderer.ts:1054

Whether a handle-bearing mode is selected, and whether that mode scopes handles to the selection. Set by the interaction layer, because the mode is its state; the renderer only needs to know whether to draw chrome, and for which graphics.

Parameters ​

active ​

boolean

selectionScoped? ​

boolean = false

Returns ​

void


setMeasure() ​

ts
setMeasure(
   line, 
   caption?, 
   parts?
): void;

Defined in: components/maplibre/native/NativeLayerRenderer.ts:765

Shows the radius read-out, or clears it.

A hashed line from the center to the rim with the distance on it, drawn while a circular graphic is sized — the same chrome as OpenLayers' measure feature, and deliberately the same words: both call formatDistance, so the read-out, the other renderer's read-out and the properties dialog cannot disagree about a number the user is comparing.

Editor chrome, so it lives in its own source rather than in the paint buckets: it must never reach snapshot, a sample sweep or a restored map.

Parameters ​

line ​

| [ProjectedPosition, ProjectedPosition] | null

caption? ​

string

parts? ​

MeasurePart[]

Returns ​

void


setPreview() ​

ts
setPreview(graphic): void;

Defined in: components/maplibre/native/NativeLayerRenderer.ts:1077

The graphic being drawn, painted but not owned.

Held apart from graphics on purpose. It is not a graphic the map has — it is a picture of the one the next click would create — so it must not appear in a snapshot, in count, or under a hit test, all of which read graphics. Passing it through add/remove would have put it in all three, and a save taken mid-gesture would have persisted a symbol the user never committed to.

Parameters ​

graphic ​

PaintedGraphic | null

Returns ​

void

See ​

MapLibreInteractions.previewDraw


setSketch() ​

ts
setSketch(points): void;

Defined in: components/maplibre/native/NativeLayerRenderer.ts:808

Sets the line being drawn, or clears it. Repaints only the editor chrome.

Parameters ​

points ​

ProjectedPosition[] | null

Returns ​

void


setVertexHint() ​

ts
setVertexHint(position): void;

Defined in: components/maplibre/native/NativeLayerRenderer.ts:799

Marks where a drag would add a vertex, or clears the mark.

Called on every pointer move in modify mode, so it returns early when nothing changed: repainting the editor marks on each mousemove would rebuild the handle source hundreds of times a second for a dot that has not moved.

Parameters ​

position ​

ProjectedPosition | null

Returns ​

void


snapshot() ​

ts
snapshot(): FeatureCollection;

Defined in: components/maplibre/native/NativeLayerRenderer.ts:514

Every graphic as a plain GeoJSON FeatureCollection — one base feature each, the same shape serializeTacticalGraphics produces on the OpenLayers side.

The base is all that is saved because everything else is derived: the geometry, the decorations and the labels all regenerate from properties.tacticalGraphic, which is the portable description any renderer consumes. Saving the drawn output instead would produce a picture rather than a graphic.

Returns ​

FeatureCollection

Released under the MIT License.