// the find
JamesLMilner/terra-draw
A library for drawing on maps that supports Mapbox, MapLibre, Google Maps, OpenLayers and Leaflet out the box
Terra Draw is a TypeScript library that abstracts map drawing interactions across six major mapping libraries (Leaflet, MapLibre, Mapbox, OpenLayers, Google Maps, ArcGIS) behind a single adapter interface. You get points, lines, polygons, circles, freehand drawing, and selection/edit modes without rewriting input handling for each map library. Aimed at devs building geospatial editors or annotation tools who don't want to be locked into one mapping library.
The adapter pattern is the right call — swapping from Leaflet to MapLibre doesn't require rewriting your drawing logic, just the adapter. Geodesic/rhumb line support is built in with its own geometry math rather than depending on turf.js, which keeps the bundle lean. The mode system is properly composable: behaviors (snapping, undo/redo, coordinate insertion) are separate classes you mix into modes rather than one giant stateful blob. Test coverage is thorough — every mode and behavior has a spec file, and there's a separate e2e Playwright suite.
Each adapter ships as its own npm package, which means six separate version pins to keep in sync in a monorepo — that version drift will eventually bite someone. E2e tests only cover Leaflet; if you're using MapLibre or OpenLayers you're trusting unit tests alone for integration correctness. No built-in serialization/deserialization beyond raw GeoJSON — if you need undo history persistence or collaborative editing state, you're on your own. The store's spatial index is a vendored rbush copy rather than a declared dependency, which complicates security audits.