Jin Igarashi
Software Engineer, Fracta Inc
An introduction for newcomers
Until you have to build it.
Leaflet.draw, leaflet-freedraw, mapbox-gl-draw... different APIs, different behaviour, different bugs — and your drawing code is locked to one map.
An open source TypeScript library for drawing on web maps, created by James Milner about four years ago.
One drawing engine, many maps.
npm install terra-draw
Adapter talks to the map · Modes own the interaction · Store holds the GeoJSON.
Swap the adapter, keep everything else.
point
linestring
polygon
marker
polyline
rectangle
angled-rectangle
circle
sector
sensor
freehand
freehand-linestring
select
What does TerraDraw help you achieve?
import { TerraDraw, TerraDrawPolygonMode } from 'terra-draw'; import { TerraDrawMapLibreGLAdapter } from 'terra-draw-maplibre-gl-adapter'; const draw = new TerraDraw({ adapter: new TerraDrawMapLibreGLAdapter({ map }), modes: [new TerraDrawPolygonMode({ snapping: true })] }); draw.start(); draw.setMode('polygon');
draw.on('finish', (id) => { const snapshot = draw.getSnapshot(); const feature = snapshot.find((f) => f.id === id); console.log(JSON.stringify(feature)); });
getSnapshot() / addFeatures() — load, save and round-trip your features with anything that speaks GeoJSON.
getSnapshot()
addFeatures()
New features to use in your project
Common in every drawing application, one of the most requested features — and hard to get right.
draw.undo(); draw.redo();
New ways to style your geometries — style callbacks receive the feature, so colour, width and opacity can depend on your own properties.
line mode now supports dashed lines, with a new lineStringDash style property.
lineStringDash
Lines that can be closed into polygons: start drawing a line and finish it as an area, without switching mode.
Register one mode twice with different configurations — for example two polygon modes with different styling and validation.
Click and drag support: drag out a rectangle or a circle in one gesture instead of clicking corner by corner.
Terra Draw gives you the drawing engine — the buttons, the mode switching and the map controls are yours to write.
A MapLibre GL JS plugin: Terra Draw plus a ready-made control.
npm install @watergis/maplibre-gl-terradraw
Then, just one line of code to add the control to your MapLibre map:
import { MaplibreTerradrawControl } from '@watergis/maplibre-gl-terradraw'; map.addControl( new MaplibreTerradrawControl({ open: true }), 'top-left' );
MaplibreMeasureControl adds distance and area labels to the geometries as you draw them.
MaplibreMeasureControl
Draw a line, get a route back — the isochrone and routing controls turn drawn geometry into an API request.
UNDP's GeoHub uses the plugin for drawing and measuring.
A CesiumJS adapter for Terra Draw was released last week heading into FOSS4G 2026.
The same modes and the same GeoJSON — running on CesiumJS.
npm i @watergis/terra-draw-cesium-adapter
How you can get involved with the Terra Draw project
Thank you for listening