Explore featuresDraw Mode

Draw Shapes on the Map Draw

Draw custom shapes and annotations directly on the map. Perfect for highlighting areas of interest or planning routes.

  • Draw markers, circle markers, polylines, polygons
  • Shape tools (rectangle, circle, polygon)
  • Editable after creation
Go to Docs

The interactive map loads when JavaScript is enabled.

How to draw a polygon on a map

Pick the polygon tool in the toolbar above, then click the map to place each corner. Click the first point again to close the shape. While you draw, Geoman snaps to nearby vertices so neighbouring areas line up. After drawing, switch to edit mode to move, add or remove vertices.

To start polygon drawing from your own code or button:

// Leaflet-Geoman
map.pm.enableDraw("Polygon")

// MapLibre-Geoman or Mapbox-Geoman
map.gm.enableDraw("polygon")

How to draw a circle on a map

Choose the circle tool, click the map to set the center, move the pointer to set the radius and click again to finish. Use map.pm.enableDraw("Circle") in Leaflet or map.gm.enableDraw("circle") in MapLibre and Mapbox. Standard GeoJSON has no circle type, so a Leaflet circle exports as a point. Store its radius, from layer.getRadius(), in the feature's properties if you need to redraw it later.

How to draw a rectangle on a map

Choose the rectangle tool and click two opposite corners. Rectangles are useful for bounding boxes, search areas and print extents. They export as ordinary GeoJSON polygons. Use map.pm.enableDraw("Rectangle") or map.gm.enableDraw("rectangle").

Lines, markers and text

The same toolbar draws polylines for routes and boundaries, markers and circle markers for points, and text labels. Pro adds freehand drawing and custom shapes. Every tool fires the same create event, pm:create in Leaflet and gm:create in MapLibre and Mapbox, so one handler can save every new shape.

Export your shapes as GeoJSON

Read everything the user drew as a FeatureCollection:

// Leaflet-Geoman
const data = map.pm.getGeomanLayers(true).toGeoJSON()

// MapLibre-Geoman or Mapbox-Geoman
const data = map.gm.features.exportGeoJson()

Send the result to your API, or save it as a .geojson file. To draw shapes and download GeoJSON without writing code, use the free Geoman GeoJSON Editor.

Next steps