Leaflet.draw and Leaflet-Geoman both add drawing and editing to a Leaflet map. Moving from one to the other keeps your map, tile layers and GeoJSON storage. What changes is how you create the toolbar, start drawing from code, style shapes and listen for changes. This guide maps each Leaflet.draw call to its Geoman equivalent and gives you a working editor to start from. For a feature and licensing comparison, see Leaflet-Geoman vs Leaflet.draw.

What changes when you migrate?

Leaflet.draw is built around a control (L.Control.Draw), one handler class per shape (L.Draw.Polygon, L.Draw.Circle and so on) and events named in L.Draw.Event. Starting a tool from your own button usually means creating a handler and calling enable(), or reaching into the control's private _toolbars object.

Leaflet-Geoman puts everything on map.pm (the map) and layer.pm (each layer). The toolbar, the draw tools and the edit modes all have public methods, and events start with pm:. Geoman adds drawn layers to the map for you, so you no longer call addLayer in a draw:created handler.

Leaflet-Geoman Free includes drawing, vertex editing, dragging, rotation, cutting and snapping. Splitting, scaling, measurements and auto tracing need Pro. The documentation marks Pro features with a star.

A working Leaflet editor

This example uses Leaflet 1.9.4 and Leaflet-Geoman Free 2.20. Install the packages:

npm install leaflet@^1.9.4 @geoman-io/leaflet-geoman-free@^2.20

Add a container with an explicit height:

<div id="map" style="height: 480px"></div>

Save this module as editor.js:

import L from "leaflet"
import "leaflet/dist/leaflet.css"
import "@geoman-io/leaflet-geoman-free"
import "@geoman-io/leaflet-geoman-free/dist/leaflet-geoman.css"

export function createEditor(
  container,
  initialData = { type: "FeatureCollection", features: [] },
) {
  const map = L.map(container).setView([0, 0], 2)
  // Add your application's tile layer here.
  const editableLayers = L.featureGroup().addTo(map)
  L.geoJSON(initialData).eachLayer((layer) => editableLayers.addLayer(layer))

  map.pm.setGlobalOptions({ layerGroup: editableLayers, snappable: true })
  map.pm.addControls({
    drawMarker: false,
    drawCircleMarker: false,
    drawCircle: false,
    drawText: false,
    cutPolygon: false,
    rotateMode: false,
  })
  map.on("pm:remove", ({ layer }) => editableLayers.removeLayer(layer))

  return { map, getData: () => editableLayers.toGeoJSON() }
}

Create the editor from your entry point, passing your existing FeatureCollection:

import { createEditor } from "./editor.js"

const editor = createEditor("map", savedGeoJson)
editor.map.pm.enableDraw("Polygon")

Call editor.getData() from your Save action and send the result to your API. The example keeps a feature group as the export boundary and turns off circle drawing, because standard GeoJSON does not store a circle's radius. In an SSR framework, create the editor after the component mounts, and call editor.map.remove() when it unmounts.

Leaflet.draw to Leaflet-Geoman API mapping

These are starting points, not identical signatures. Check the Leaflet.draw API and the Geoman draw mode and edit mode pages for your installed versions.

Task Leaflet.draw Leaflet-Geoman
Add the toolbar map.addControl(new L.Control.Draw({ edit: { featureGroup } })) map.pm.addControls({ position: "topleft" })
Keep drawn shapes in a group edit.featureGroup option, plus featureGroup.addLayer(e.layer) on create map.pm.setGlobalOptions({ layerGroup: featureGroup })
Start polygon drawing from code new L.Draw.Polygon(map, options).enable() map.pm.enableDraw("Polygon", options)
Start a toolbar handler drawControl._toolbars.draw._modes.polygon.handler.enable() map.pm.enableDraw("Polygon")
Stop drawing handler.disable() map.pm.disableDraw()
Change drawing styles drawControl.setDrawingOptions({ polygon: { shapeOptions: { color } } }) map.pm.setPathOptions({ color }), or templineStyle, hintlineStyle and pathOptions in setGlobalOptions
Edit all shapes new L.EditToolbar.Edit(map, { featureGroup }).enable() map.pm.enableGlobalEditMode()
Edit one shape layer.editing.enable() layer.pm.enable()
Delete by clicking new L.EditToolbar.Delete(map, { featureGroup }).enable() map.pm.enableGlobalRemovalMode()
Translate the UI L.drawLocal map.pm.setLang("de") or a custom translation

Events

Leaflet.draw event Leaflet-Geoman event Notes
L.Draw.Event.CREATED (draw:created) pm:create on the map The layer is already on the map, or in your layerGroup.
L.Draw.Event.EDITED (draw:edited) pm:edit on each layer Fires while editing; debounce saves. pm:globaleditmodetoggled fires when edit mode ends.
L.Draw.Event.DELETED (draw:deleted) pm:remove on the map or layer Fires once per removed layer.
L.Draw.Event.DRAWSTART / DRAWSTOP pm:drawstart / pm:drawend The payload includes shape.
L.Draw.Event.DRAWVERTEX pm:vertexadded on the working layer Get the working layer from pm:drawstart.
L.Draw.Event.EDITSTART / EDITSTOP pm:globaleditmodetoggled Check e.enabled.
L.Draw.Event.TOOLBAROPENED / TOOLBARCLOSED No direct equivalent Geoman's toolbar has no open state. Use pm:drawstart and pm:drawend, or pm:buttonclick for toolbar clicks.

Here is a typical Leaflet.draw save handler and its Geoman version:

// Leaflet.draw
map.on(L.Draw.Event.CREATED, (e) => {
  drawnItems.addLayer(e.layer)
  save(drawnItems.toGeoJSON())
})

// Leaflet-Geoman
map.pm.setGlobalOptions({ layerGroup: drawnItems })
map.on("pm:create", ({ layer }) => {
  layer.on("pm:edit", () => save(drawnItems.toGeoJSON()))
  save(drawnItems.toGeoJSON())
})
map.on("pm:remove", () => save(drawnItems.toGeoJSON()))

Preserve your GeoJSON and save behavior

Start with a real FeatureCollection from your application. Import it with L.geoJSON, add the layers to the group you pass as layerGroup, then draw, edit and delete. Export with toGeoJSON() and compare geometry types, IDs and properties with what you stored before.

Test this sequence before migrating real user data:

  1. Import a saved collection and check feature counts, properties and IDs.
  2. Draw a polygon, move a vertex, cut a hole and delete a feature.
  3. Export, reload the result and compare it with what the user saw.
  4. Repeat with large shapes, multi-geometries and your users' devices.
  5. Remove the Leaflet.draw control while testing, so the two plugins do not compete for the same clicks.

Choose Free or Pro after testing the workflow

Start with Free if its tools cover your editor. Evaluate Pro when splitting, scaling, measurements or auto tracing would replace code you would otherwise write and maintain. Try those tools in the Leaflet demo, which includes Pro features, and review license and support plans.

Leaflet.draw and Leaflet-Geoman Free both use the MIT license. Leaflet-Geoman Pro is licensed separately from MapLibre/Mapbox-Geoman Pro.