A custom Terra Draw mode that lets users place, edit, and drag freeform text
labels anywhere on the map.
Interaction model
Gesture
Behaviour
Click on the map
Opens a textarea popup at the clicked location.
Enter (or Submit button)
Commits the label as a Point GeoJSON feature with a text property. Calls onTextCommit and fires the TerraDraw finish event.
Shift+Enter
Inserts a newline without committing.
Escape (in popup)
Dismisses the popup and deletes the uncommitted feature.
Click outside open popup
Commits any typed text, or dismisses if empty.
Click near existing label
Opens the textarea pre-filled with existing text (requires editable: true).
Drag a committed label
Handled by TerraDrawSelectMode when flags.text.feature.draggable is true.
MapLibre GL rendering
TerraDrawTextMode itself only stores Point features in the TerraDraw store.
MaplibreTerradrawControl detects the text mode and maintains a
separate {prefix}-text-labels MapLibre symbol layer that reads the text
property from the GeoJSON source. This means the labels are rendered by
MapLibre GL and support all standard text-* paint/layout properties.
A custom Terra Draw mode that lets users place, edit, and drag freeform text labels anywhere on the map.
Interaction model
PointGeoJSON feature with atextproperty. CallsonTextCommitand fires the TerraDrawfinishevent.editable: true).TerraDrawSelectModewhenflags.text.feature.draggableistrue.MapLibre GL rendering
TerraDrawTextModeitself only stores Point features in the TerraDraw store.MaplibreTerradrawControldetects thetextmode and maintains a separate{prefix}-text-labelsMapLibre symbol layer that reads thetextproperty from the GeoJSON source. This means the labels are rendered by MapLibre GL and support all standardtext-*paint/layout properties.Usage