Function bindTerraDrawSketch

  • Experimental

    Bind a terra-draw instance to an EditSketchWorkflowModel (REQ-001).

    Every terra-draw finish event (freshly drawn features and select-mode edits: dragged features, dragged/inserted/deleted coordinates) maps the finishing mode to an EditSketchTool and applies the feature geometry through model.setSketchGeometry, so workflow undo/redo and validation cover terra-draw edits. Deleting the tracked feature stages a null geometry through the same undoable path.

    The caller owns the terra-draw instance lifecycle (start/stop); the binding only attaches listeners and detaches them in remove().

    Type Parameters

    • T = Record<string, unknown>

    Returns TerraDrawSketchHandle

    const workflow = createEditSketchWorkflow({ source, sketchTools: terraDrawSketchToolCapabilities() });
    const handle = bindTerraDrawSketch(draw, { model: workflow });
    handle.setTool("polygon"); // draw.setMode("polygon") + workflow arming
    // ... user draws; workflow.snapshot().sketch.geometry now tracks terra-draw
    handle.undo(); // workflow history, mirrored back into terra-draw
    await workflow.submit(); // edit-session applyEdits path, unchanged