# Element Editor > Element Editor is a map drawing and GeoJSON editing library for React: users draw, edit and attach data to shapes on MapLibre or Leaflet maps. Use the drop-in editor (MapLibre) or bring your own MapLibre or Leaflet map; Element adds drawing tools, vertex editing, snapping, boolean operations, geometry processing, a typed schema layer, a data table, and a two-way GeoJSON editor. Open source under the MIT License — free for any use, including commercial. Element Editor ("Element" for short, not related to the Matrix chat app Element, Element UI or Element Plus) is a JavaScript and TypeScript library for adding vector editing to web maps. Requires React 19.2 or newer (React 18 is not supported). Distributed as these user-facing packages: - `@element-editor/react` — self-contained `` component on MapLibre, with built-in basemaps and a basemap picker. Owns the map. Zero configuration required. The Leaflet version of the same component is at `@element-editor/react/leaflet`. - `@element-editor/adapter-leaflet` — plugs editing into an existing Leaflet or react-leaflet map. - `@element-editor/adapter-maplibre` — plugs editing into an existing MapLibre GL, MapTiler SDK, or Mapbox GL JS map. - `@element-editor/ui` — individual UI components (toolbars, panels, modals) for building custom editor layouts with an adapter. - `@element-editor/core` — the stores, types and helpers the others share (no UI). Only its root entry is public API; `@element-editor/core/internal` and `@element-editor/ui/internal` are unstable internals, not for application code. The current version is 0.4.0 (all packages share one version); 0.2.0 was the first release on npm (0.1.0 was a pre-release that was never published). All packages output standard RFC 7946 GeoJSON. Peer dependencies: `react` / `react-dom` `^19.2`; `maplibre-gl` `^5.5.0 || ^6.0.0` for `@element-editor/react` and the MapLibre adapter; `leaflet` `^1.9` and `react-leaflet` `^5` for the Leaflet adapter and for `@element-editor/react/leaflet`, which also needs `@element-editor/adapter-leaflet` (these are optional peers of `@element-editor/react`, so Leaflet users install them; TypeScript users of the Leaflet entries also need `@types/leaflet`). Import one stylesheet: `@element-editor/react/style.css` (includes MapLibre's CSS), `@element-editor/react/leaflet/style.css` or `@element-editor/adapter-leaflet/style.css` (both include Leaflet's CSS), or `@element-editor/adapter-maplibre/style.css`; there is no `@element-editor/ui/style.css`. The stylesheets don't reset the host page: base styles apply only inside `[data-elm-theme]` elements, so adapter users render the map and UI inside one, wrapped in `ElementEditorUIProvider` and `GeoStoreProvider`. A single inlined geometry worker runs boolean operations, cut hole, slice and the buffer/simplify/smooth previews; import, export and validation run on the main thread. No bundler configuration is needed for the drop-ins: on MapLibre GL JS 6, whose worker is a separate file, the MapLibre drop-in loads it from jsDelivr at the installed version (`config.network.maplibreWorker` points it at your own copy; `false` leaves MapLibre's `setWorkerUrl` to your app), while `@element-editor/adapter-maplibre` users call `setWorkerUrl` themselves before creating their map (MapLibre 5 has the worker built in). A Content-Security-Policy needs `worker-src blob:` and `style-src 'unsafe-inline'`, plus `script-src https://cdn.jsdelivr.net` for the default MapLibre 6 worker. Eager JavaScript (gzip, Vite production build of 0.2.1): about 510 KB for the MapLibre drop-in on maplibre-gl 6, of which React and MapLibre GL are about 345 KB, and about 270 KB for the Leaflet drop-in; the data table, schema editor, GeoJSON editor and heavy geometry code load on first use. Features can carry typed, validated properties defined by user schemas; schemas travel with the data as a foreign member (`metadata.schemas`). Element Editor is fully open source. Every capability that ships today — every drawing tool (point, line, area, rectangle, circle, freehand, road-snapped route, OpenStreetMap picker), vertex editing, selection, transform, snapping, boolean operations, geometry processing, the measure tool, the typed-schema API and in-app schema editor, the data table with inline editing, the two-way GeoJSON editor, import and export — is MIT-licensed and free for any use, including commercial. There is no runtime license check, no usage reporting, no attribution requirement beyond the standard MIT notice (map data credits, shown automatically on the map, still apply). A future Pro tier with team-oriented extensions will ship under a separate paid commercial license; it is not available yet. For coding agents: the whole documentation is one file at https://elementeditor.dev/llms-full.txt, and every docs page is also plain markdown at its URL plus `.md` (the docs links below already point there). Each npm package ships an `AGENTS.md` with install commands, minimal examples and common mistakes. Basic setup: `npm install @element-editor/react maplibre-gl`, `import '@element-editor/react/style.css'`, render `` inside a parent with an explicit height; in Next.js render it client-only (`'use client'` plus `next/dynamic` with `ssr: false`; on Next.js 15, upgrade React to 19.2 first). ## Drive the editor from code `` (both entries) exposes an imperative ref, typed `ElementEditorRef`. Load data with the `initialData` prop (applied once: at mount, or the first time it becomes data while the editor is still empty and unedited, so fetch → setState → `initialData={data}` works; later changes are ignored with a dev warning; loading it is not an undo step and does not fire `onChange`). Standard `@types/geojson` data type-checks as input (3D positions, 6-number bbox, `GeometryCollection`; null-geometry features are skipped and reported via `onError`). Load or replace data later with the ref; save with the `onChange` prop (called with the full `FeatureCollection` after every committed edit) or read it on demand. - Data: `getFeatureCollection(): FeatureCollection`, `setFeatureCollection(data, { silent?, undoable? })` (replaces everything, one undo step; `silent: true` skips `onChange` so loading from your backend doesn't echo a save; `undoable: false` starts a fresh history), `getFeature(id): GeoJSONFeature | null`, `importGeoJSON(raw, 'replace' | 'merge'): ImportResult`, `exportGeoJSON(): string`, `exportAs('geojson')` (browser download) - Features: `addFeature(feature, options?): GeoJSONFeature | null` (a missing id gets a UUID), `updateFeature(id, patch, options?): boolean`, `updateFeatures([{ id, patch }], options?)`, `removeFeatures(ids, options?): number`; a `patch` sets `properties` (whole object), `geometry`, `schemaId` or `hidden`; `options.undoable` (default `true`) makes the change an undo step - Selection and tools: `getSelection(): string[]`, `select(ids, { fit? })`, `clearSelection()`, `setTool(tool | null): boolean` (`'point' | 'line' | 'polygon' | 'rectangle' | 'circle' | 'freehand' | 'route' | 'picker' | 'measure'`; `'polygon'` is the tool labelled Area in the UI; returns `false` when the tool isn't available or the editor is `readonly`), `getTool(): DrawTool | null`, and the `onToolChange` prop - History and validation: `undo()`, `redo()`, `canUndo(): boolean`, `canRedo(): boolean`, `validate(): { valid, errors }` (schema check of every feature, errors keyed by feature id, no submit), `submit(): boolean` (validates every feature, then calls `onSubmit` with the data, or `onValidationError` and returns `false`) - `readonly` blocks every user edit (tools, table, inspector, import, file drop, undo); the ref's data methods keep working so your app stays in charge. Dropping a `.geojson` file on the map imports it (`fileDrop={false}` turns that off). - Map: `getMap()` (the MapLibre `Map`, or the Leaflet `Map` for `/leaflet`; `null` before it exists), `flyTo({ center: [lng, lat], zoom? })`, `setZoom(zoom): boolean`, `fitBounds([west, south, east, north])` (`flyTo`, `fitBounds` and `select(ids, { fit: true })` frame the target in the part of the map the panels leave visible, so `map.getCenter()` can differ from the requested centre), `getBasemap()`, `setBasemap(basemap)` Full signatures: [ElementEditorRef](https://elementeditor.dev/docs/reference/element-editor-react.md#elementeditorref). Coordinates are GeoJSON order, `[lng, lat]`, everywhere except Leaflet's own APIs. ## Product - [Features overview](https://elementeditor.dev/features): index of all capability pages - [Playground](https://elementeditor.dev/playground): full interactive editor in the browser, no install, shareable URL state - [Pricing](https://elementeditor.dev/pricing): MIT-licensed today, future Pro tier - [License](https://elementeditor.dev/license): full MIT license text ## Quickstart - [Quickstart — @element-editor/react](https://elementeditor.dev/docs/quickstart/react.md): drop-in editor in five minutes (MapLibre; Leaflet via `/leaflet`, with an upgrade note) - [Quickstart — adapter-leaflet](https://elementeditor.dev/docs/quickstart/adapter-leaflet.md): add editing to an existing Leaflet map - [Quickstart — adapter-maplibre](https://elementeditor.dev/docs/quickstart/adapter-maplibre.md): MapLibre GL, MapTiler SDK, and Mapbox GL JS - [Choosing a package](https://elementeditor.dev/docs/introduction/choosing-a-package.md): three-question decision tree - [GeoJSON primer](https://elementeditor.dev/docs/introduction/geojson-primer.md): the data format Element reads and writes ## Features - [Drawing tools](https://elementeditor.dev/features/drawing): point (P), line (L), area (G; tool id `'polygon'`, draws a `Polygon`), rectangle (R), circle (O), freehand (F), road-snapped route (C), picker (X — imports shapes from OpenStreetMap). Drag-to-draw on rectangles and circles. Spacebar pans without leaving the active tool. - [Vertex editing](https://elementeditor.dev/features/vertex-editing): drag to move, click edge midpoints to insert, Backspace to delete. Circles, rectangles and routes become plain shapes on the first point edit (one undo brings the original back); move, scale and rotate keep them what they are - [Selection and transform](https://elementeditor.dev/features/selection-transform): click, shift-click, lasso, Cmd/Ctrl+A select-all; press A to scale and rotate; Cmd/Ctrl+G groups, Cmd/Ctrl+Shift+G ungroups; Cmd/Ctrl+E opens the edit panel for the selection - [Snapping](https://elementeditor.dev/features/snapping): magnetic snap to nearby vertices and edges while drawing or editing - [Boolean operations](https://elementeditor.dev/features/boolean-operations): union, intersect, subtract, cut hole (H), slice (J); each is one undo step and runs in the geometry worker - [Geometry processing](https://elementeditor.dev/features/geometry-processing): buffer, simplify, smooth (polygons and lines; buffering a line gives a polygon), break apart (B), merge — `config.units.length` is `'metric' | 'imperial' | 'auto'`; user override persisted in localStorage (key `elm_units`) - [Measure](https://elementeditor.dev/features/measure): distance and area overlays without adding features (M) - [Schemas and typed data](https://elementeditor.dev/features/schema-driven-data): typed fields (text, textarea, number, url, select, date, boolean); define schemas in code or edit them in-app (S); schemas travel with the GeoJSON as `metadata.schemas` - [Data table](https://elementeditor.dev/features/data-table): spreadsheet view with inline editing and map-selection sync (T); virtualized for large collections - [GeoJSON editor](https://elementeditor.dev/features/geojson-inspector): two-way editing of the raw FeatureCollection (I); valid edits apply as you type, invalid JSON is underlined with a status line and applies nothing until fixed, and unapplied text is kept as a draft when the editor closes; CodeMirror 6 under the hood - [Import and export](https://elementeditor.dev/features/import-export): GeoJSON in and out via file (Cmd/Ctrl+O, Cmd/Ctrl+S), dropping a file on the map (`fileDrop` prop, default `true`), paste into the GeoJSON editor, or `ref.importGeoJSON(fc, 'replace' | 'merge')`; Google Sheets CSV helpers in `@element-editor/core` - [Keyboard shortcuts](https://elementeditor.dev/features/keyboard-shortcuts): every tool has a default key; every tool key is remappable (K). Storage key: `elm_shortcuts`. - [Theming](https://elementeditor.dev/features/theming): the `theme` prop sets the mode only (`'light' | 'dark' | 'auto'`; follows the OS by default; an object is ignored with a development warning); brand colour from one value (`accentColor` prop, `config.accentColor`, ``, `style={{ '--elm-accent': … }}`, or CSS `--elm-accent`) that generates the whole 50–950 accent scale for the UI and the map highlights; `--elm-primary-N` overrides one shade; 23 design tokens restyle the chrome per mode and per editor (`--elm-font`, `--elm-font-mono`, `--elm-radius`, `--elm-radius-control`, `--elm-surface*`, `--elm-control-hover`, `--elm-text*`, `--elm-border*`, `--elm-focus-ring`, `--elm-shadow*`, `--elm-tooltip`, `--elm-tooltip-text`), set in CSS on `:root`, `[data-elm-theme="light"|"dark"]` or a class on the editor root, or through `style`; Element copies them onto its body-level portals (menus, modals, tooltips); defaults keep the standard look; feature colours stay props: `featureColor` (all features) and `getFeatureStyle` (per feature) - [Map styles](https://elementeditor.dev/features/map-styles): built-in basemaps in the default `` (props `defaultBasemap`, default `'auto'`, the user's pick is remembered; `basemap` + `onBasemapChange` to control it from your app; `basemaps`, the picker list, `false` hides it) and in `@element-editor/adapter-maplibre/basemaps` — `streets`, `terrain`, `light`, `dark` (OpenFreeMap vector tiles, no API key), `osm` (OpenStreetMap raster), `'auto'` (streets in light theme, dark in dark); `setBasemap(map, input, { theme, network })` switches styles and keeps Element's layers and your own; `BasemapControl` is the picker for adapter hosts; custom `{ style }` or raster `{ url, attribution }`. The Leaflet drop-in is raster only (`tileLayer`, or a `basemaps` list of two or more for a picker) - [UI customization](https://elementeditor.dev/features/ui-customization): `layout` prop (`'panel' | 'minimal' | 'split'`); `config.ui.layout` puts any built-in control (toolbar, undo/redo, fit bounds, zoom, table, schema, GeoJSON, settings, Apply changes, attribution) in a map corner, edge center or status bar, with groups and separators; unlisted controls are hidden (except the map attribution, which shows expanded at load and folds into an (i) button after 5 seconds or the first interaction); below 640 px of editor width the layers panel and docked GeoJSON editor open over the map; `slots` adds your own React with the exported `IconButton`/`Tooltip`; adapters + `@element-editor/ui` for a fully custom shell ## Compare - [Element Editor vs Geoman](https://elementeditor.dev/compare/geoman): feature-by-feature comparison - [Element Editor vs Leaflet.Draw](https://elementeditor.dev/compare/leaflet-draw) - [Element Editor vs Mapbox GL Draw](https://elementeditor.dev/compare/mapbox-gl-draw) - [Element Editor vs Terra Draw](https://elementeditor.dev/compare/terra-draw) ## Reference - [@element-editor/react API](https://elementeditor.dev/docs/reference/element-editor-react.md): `ElementEditorProps`, `ElementEditorRef`, all exports - [@element-editor/adapter-leaflet API](https://elementeditor.dev/docs/reference/adapter-leaflet.md): `ElementEditorControlsProps`, `ElementEditorControlsRef` - [@element-editor/adapter-maplibre API](https://elementeditor.dev/docs/reference/adapter-maplibre.md): same API plus `map` prop and `useMapLibre` hook - [@element-editor/ui API](https://elementeditor.dev/docs/reference/element-editor-ui.md): providers, hooks, and individual UI components - [Types](https://elementeditor.dev/docs/reference/types.md): `FeatureCollection`, `GeoJSONFeature`, `Schema`, `SchemaField`, `Group`, `Geometry`, `EditingMode` - [Events](https://elementeditor.dev/docs/reference/events.md): `onChange`, `onSubmit`, `onFeatureAdd`, `onFeatureUpdate`, `onFeatureDelete`, `onSelectionChange`, `onZoomChange`, `onValidationError`, `onEvent` (every user-facing message; when set, the editor shows no toasts), `onError` (every runtime failure as an `ElementEditorError` with a stable `code` and `source`; return `false` to hide the toast or a string to replace it) ## Guides - [Migrating to 0.2](https://elementeditor.dev/docs/guides/migrating-to-0.2.md): `@element-editor/react` is now MapLibre (Leaflet at `/leaflet`), bbox `bounds`, `flyTo({ center, zoom })`, `T`/`A` shortcuts, `persistKey`, `config.network`, `config.ui.layout` - [Persisting data](https://elementeditor.dev/docs/guides/persisting-data.md): localStorage, a REST API, or a database - [Live vs submit mode](https://elementeditor.dev/docs/guides/live-vs-submit.md): when to listen to every edit, when to wait for Save - [Schema and validation](https://elementeditor.dev/docs/guides/schema-and-validation.md): typed property fields, required rules, validation events - [Configuring layout](https://elementeditor.dev/docs/guides/configuring-layout.md): `config.ui.layout` places any built-in control in map slots or a status bar (unlisted controls hidden), toolbar direction, `slots` for your own JSX - [Theming](https://elementeditor.dev/docs/guides/theming.md): match the editor to your product identity - [Restricting tools](https://elementeditor.dev/docs/guides/restricting-tools.md): limit the tool set exposed to users - [Custom UI with adapters](https://elementeditor.dev/docs/guides/custom-ui-with-adapters.md): place toolbars and panels in your own layout - [Basemaps](https://elementeditor.dev/docs/guides/basemaps.md): built-in basemaps and picker, custom styles and raster tiles, Leaflet `tileLayer` - [Third-party services and self-hosting](https://elementeditor.dev/docs/guides/third-party-services.md): every server Element calls (OpenFreeMap tiles and fonts, Mapterhorn elevation, OSM raster, the jsDelivr sprite and MapLibre 6 worker, Overpass for the Picker, the OSRM demo router, Nominatim search), the Content Security Policy it needs, and `config.network` to point each at your own server or key, per editor, or turn it off (`false`) - [Using Element Editor with Next.js](https://elementeditor.dev/docs/guides/nextjs.md): load the editor with `next/dynamic` and `ssr: false` (the MapLibre drop-in would only server-render its loading shell; the Leaflet drop-in can't be imported on the server at all), React 19.2 on Next.js 15 - [Working with large datasets](https://elementeditor.dev/docs/guides/saving-large-datasets.md): performance patterns for hundreds or thousands of features ## Optional - [Changelog](https://elementeditor.dev/changelog): release notes and product updates ([0.2.2](https://elementeditor.dev/changelog/element-0-2-2), clearer drawing hints; [0.2.1](https://elementeditor.dev/changelog/element-0-2-1), MapLibre GL JS 6 support; [0.2.0, the first npm release](https://elementeditor.dev/changelog/element-0-2-0)) - [GitHub repository](https://github.com/spatibase/element): source, issues, discussions - [All docs in one file](https://elementeditor.dev/llms-full.txt): every docs page below, concatenated - [Introduction: What is Element Editor](https://elementeditor.dev/docs/introduction/what-is-element.md): A drawing and editing layer that plugs into your map. - [Introduction: Choosing a package](https://elementeditor.dev/docs/introduction/choosing-a-package.md): Three questions to find your starting point. - [Introduction: GeoJSON primer](https://elementeditor.dev/docs/introduction/geojson-primer.md): Everything Element Editor needs you to know about the data format — and nothing more. - [Quickstart: Quick start: @element-editor/react](https://elementeditor.dev/docs/quickstart/react.md): A complete map editor in your React app — no map setup required. Estimated time: ~5 minutes. - [Quickstart: Quick start: Leaflet adapter](https://elementeditor.dev/docs/quickstart/adapter-leaflet.md): Add Element Editor drawing tools to your existing Leaflet map. Estimated time: ~10 minutes. - [Quickstart: Quick start: MapLibre adapter](https://elementeditor.dev/docs/quickstart/adapter-maplibre.md): Add Element Editor drawing tools to your existing MapLibre GL, MapTiler SDK, or Mapbox GL JS map. Estimated time: ~10 minutes. - [Guides: Migrating to 0.2](https://elementeditor.dev/docs/guides/migrating-to-0.2.md): Upgrade an app from Element Editor 0.1 to 0.2. - [Guides: Persisting data](https://elementeditor.dev/docs/guides/persisting-data.md): Get feature data out of the editor and into your storage layer. - [Guides: Live mode vs submit mode](https://elementeditor.dev/docs/guides/live-vs-submit.md): When to listen to every edit, when to wait for a Save click. - [Guides: Schema and validation](https://elementeditor.dev/docs/guides/schema-and-validation.md): Give your features structured, typed properties. - [Guides: Configuring the editor layout](https://elementeditor.dev/docs/guides/configuring-layout.md): Where every button sits, how buttons group and stack, and how to slot your own UI alongside the built-ins. - [Guides: Basemaps](https://elementeditor.dev/docs/guides/basemaps.md): Built-in basemaps, a picker, and your own styles. - [Guides: Third-party services and self-hosting](https://elementeditor.dev/docs/guides/third-party-services.md): Out of the box Element Editor talks to free public services: basemap tiles, fonts and elevation from OpenFreeMap and Mapterhorn, OpenStreetMap raster tiles, the Picker's Overpass lookups, the Route… - [Guides: Theming](https://elementeditor.dev/docs/guides/theming.md): Match the editor to your product's visual identity. - [Guides: Restricting tools](https://elementeditor.dev/docs/guides/restricting-tools.md): Control exactly what users can draw and do. - [Guides: Custom UI with adapters](https://elementeditor.dev/docs/guides/custom-ui-with-adapters.md): Build the full editor experience while keeping control of your layout. - [Guides: Using Element Editor with Next.js](https://elementeditor.dev/docs/guides/nextjs.md): Render the editor client-only. - [Guides: Working with large datasets](https://elementeditor.dev/docs/guides/saving-large-datasets.md): Performance patterns for editors with hundreds or thousands of features. - [Tools: Tools overview](https://elementeditor.dev/docs/tools/overview.md): All drawing tools and editing modes at a glance. - [Tools: Drawing tools](https://elementeditor.dev/docs/tools/drawing-tools.md): Eight ways to put geometry on the map. - [Tools: Vertex editing](https://elementeditor.dev/docs/tools/vertex-editing.md): Reshape features by moving, inserting, and deleting individual coordinates. - [Tools: Transform](https://elementeditor.dev/docs/tools/transform.md): Scale and rotate selected features. - [Tools: Selection](https://elementeditor.dev/docs/tools/selection.md): Select one or more features to edit, delete, or transform. - [Tools: Snapping](https://elementeditor.dev/docs/tools/snapping.md): Constrain the cursor to nearby vertices and edges while drawing. - [Tools: Boolean operations](https://elementeditor.dev/docs/tools/boolean-operations.md): Combine, subtract, and slice polygon features. - [Tools: Geometry processing](https://elementeditor.dev/docs/tools/geometry-processing.md): Reshape existing features with Buffer, Simplify, Smooth, Break apart, and Merge. - [Tools: Measure](https://elementeditor.dev/docs/tools/measure.md): Measure distances and areas without adding features to the map. - [Tools: Import and export](https://elementeditor.dev/docs/tools/import-export.md): Get GeoJSON in and out of the editor. - [Tools: Data table](https://elementeditor.dev/docs/tools/data-table.md): A spreadsheet view of all your features and their properties. - [Tools: Keyboard shortcuts](https://elementeditor.dev/docs/tools/keyboard-shortcuts.md): Draw faster. Edit faster. Don't touch the mouse more than necessary. - [Reference: @element-editor/react](https://elementeditor.dev/docs/reference/element-editor-react.md): Complete API reference for the self-contained map editor component. - [Reference: @element-editor/adapter-leaflet](https://elementeditor.dev/docs/reference/adapter-leaflet.md): Complete API reference for the Leaflet editing layer. - [Reference: @element-editor/adapter-maplibre](https://elementeditor.dev/docs/reference/adapter-maplibre.md): Complete API reference for the MapLibre GL editing layer. - [Reference: @element-editor/ui](https://elementeditor.dev/docs/reference/element-editor-ui.md): UI components for building custom editor layouts with adapter packages. - [Reference: Types](https://elementeditor.dev/docs/reference/types.md): TypeScript type reference for all Element Editor data structures. - [Reference: Events](https://elementeditor.dev/docs/reference/events.md): Reacting to changes in the editor.