🚧 These docs are a work in progress — content is incomplete and may change without notice.
Skip to content

Draw a control measure ​

draw(draft, options?) starts a draw and resolves to a GraphicSnapshot<ControlMeasure> — { graphic, render } — once the user commits. The graphic is defensively cloned, so it's safe to keep after the session ends.

Pick a control measure, press Draw, and click on the map to place points.

Loading map…
ts
const { graphic } = await td.draw({
  kind: "block",
  style: { color: "#dc2626", strokeWidth: 3 },
  properties: { source: "toolbar" }, // your metadata, copied onto the committed measure
});

measures.push(graphic);
td.render(measures);

The draft ​

Only kind is required. id (auto-generated if omitted), controlPoints (seed points for variable-length draws), options, style, and properties are all optional. The draft type is DrawMeasureDraft<K>.

Commit behaviour ​

Fixed-length kinds (Block, Disrupt, Attack-By-Fire, Support-By-Fire, Obstacle-Bypass, or any kind where minCoordinates === maxCoordinates) commit automatically on the last required click. Variable-length kinds commit on session.commit(), double-click, or a second click on the last point. Native double-click zoom is suppressed during the draw and restored after commit.

See Variable-length draw with Done / Cancel buttons for wiring a commit UI.

onCommit / onSettled ​

For a variable-length draw, session.onCommit(handler) delivers the committed snapshot exactly once, synchronously from the producing call (session.commit(), double-click, or a second click on the last point) — the same reference the draw() promise resolves with, never on abort. session.onSettled(handler) is the lifecycle complement: exactly once, on any settle path, after onCommit and after td.activeSession is already null; unlike onChange/onCommit, registering after settle still delivers, asynchronously. Same contract as EditSession's pair, singular here. Fixed-length kinds have no session and settle only through the promise.

DrawOptions ​

FieldWhat it does
signalAn AbortSignal to cancel the draw. Rejects with reason "signal".
onSessionCalled once for variable-length draws before pointer events flow. Use it to subscribe to session changes; the live session is also available as td.activeSession.
guideOpt out of the rubber-band guide (default true). Auto-suppressed for point kinds, and for fixed-length kinds unless the kind's draw rule opts back in via showGuide.
interactionStylePer-call style override. Only the guide slot is meaningful for draws; merged over the facade default and built-ins.
sizeAnchorWhere a committed pixel size is anchored — a kind's geometry size (FLOT, fortified, antitank, echelon glyphs) and the label size every text-carrying kind stamps at draw time. "ground" (default) bakes pixel sizes to meters at the finishing zoom, so the graphic becomes static; "screen" keeps them, so the graphic holds a constant on-screen size and re-renders on zoom. No-op for kinds carrying only meter sizes; never persisted.