Function createTerraDrawSnapping

  • Experimental

    Build a snapping function with terra-draw's Snapping.toCustom shape backed by the SDK snapping engine (REQ-004).

    terra-draw exposes per-mode snapping on its linestring, polygon, and polyline modes; pass the result as snapping.toCustom when constructing those modes and every drawn vertex snaps against the SnapIndex with the SDK's deterministic candidate ordering. Point, rectangle, circle, and freehand modes do not accept a snapping option in terra-draw — for those, terra-draw's pointer pipeline has no custom-snapping seam, so only terra-draw-native behavior applies.

    Type Parameters

    • T = Record<string, unknown>

    Parameters

    Returns ((event: TerraDrawSnapEvent, context: TerraDrawSnapContext) => [number, number] | undefined)

    const snap = createTerraDrawSnapping({ index, model: workflow });
    new TerraDrawPolygonMode({ snapping: { toCustom: snap } });