---
fragment_id: oscar.map.vertex-editing.002
domain: MAP
rule: Vertex editing via drag
source: app/src/map/MapView.tsx
bound_to_modules:
  - oscar.map
status: SHIPPED
version: .002
---

# Vertex editing (per codex.md §C2 vertex-edit state machine + C6 user sims 11, 12)

Vertex editing lets the operator refine the shape of an existing line or polygon by dragging individual vertices, or move a point layer's position by dragging the whole marker.

## Entry

Operator clicks "Edit vertices" in the side panel (see oscar.map.side-panel.002). The map enters vertex-edit mode for the currently selected layer:

- For line layers: each vertex of the polyline renders as a draggable circle marker, layered above the line
- For polygon layers: each vertex of the polygon renders as a draggable circle marker, layered above the polygon outline
- For point layers: the marker itself is draggable as a whole

The side panel shows a hint banner: "Edit vertices. Drag to move. Esc to cancel. Click outside to commit."

## State machine

Per codex.md §C2:

- `idle` → `dragging` on mousedown over a vertex circle
- `dragging` → `committed` on mouseup outside any cancel target (the cancel target is the side panel, the export menu, and any modal)
- `dragging` → `cancelled` on Esc press during drag

Coordinate clamping: if the operator releases the drag at a coordinate outside the map's current bounds, the coordinate is clamped to the nearest in-bounds tile before commit. The clamp is not surfaced to the operator — the marker just lands on the edge.

## Commit semantics

On commit, the new coordinate is written to the layer's `coords` array at the dragged vertex index. The layer is persisted to IDB. Version is bumped (significant edit per rules.md §10). A `LayerVersion` record is written to the `layer_versions` store with `operation: 'vertex-move'`.

## Cancel semantics

On cancel, the dragged vertex coordinate is restored to its pre-drag value. No IDB write. No version bump.

## Exit

After commit or cancel, the map returns to browse mode (vertex circles hidden). Side panel hint banner removed. The layer remains selected. Operator can re-enter vertex-edit mode by clicking "Edit vertices" again.