Cut Mode
Cut Mode

Enables drawing for the shape "Cut" to draw a polygon that gets subtracted from all underlying polygons. This way you can create holes, cut polygons or polylines in half or remove parts of it.
Important: the cutted layer will be replaced, not updated. Listen to the pm:cut event to update your layer references in your code. The pm:cut event will provide you with the original layer and returns the resulting layer(s) that is/are added to the map as a Polygon / MultiPolygon or Polyline / MultiPolyline.
// enable cutting mode
map.pm.enableGlobalCutMode({
allowSelfIntersection: false,
});
Available options are the same as in Draw Mode.
If the option layersToCut: [layer1, layer2] is passed, only this certain layers will be cutted.
The following methods are available on map.pm:
| Method | Returns | Description |
|---|---|---|
enableGlobalCutMode(options) | - | Enable Cut Mode. View Options (same as Edit Mode) |
| disableGlobalCutMode() | - | Disable Cut Mode. |
toggleGlobalCutMode(options) | - | Toggle Cut. View Options (same as Edit Mode) Mode. |
| globalCutModeEnabled() | Boolean | Returns true if global cut mode is enabled. false when disabled. |
The following events are available on a layer instance:
| Event | Params | Description | Output |
|---|---|---|---|
| pm:cut | e | Fired when the layer being cut. | shape, layer, originalLayer |
| pm:edit | e | Fired when a layer is edited / cut. | layer, shape |
The following events are available on a map instance:
| Event | Params | Description | Output |
|---|---|---|---|
| pm:globalcutmodetoggled | e | Fired when Cut Mode is toggled. | enabled, map |
| pm:cut | e | Fired when any layer is being cut. | shape, layer, originalLayer |
Cutting Circles ⭐
By default, cutting mode works on Polygons and similar shapes (Rectangles, MultiPolygons, etc).
If you want to allow your users to cut circles, pass allowCircleCut: true to the options of the global cut mode:
// enable cutting mode with a circle
map.pm.enableGlobalCutMode({
allowCircleCut: true,
});
Cut as a Circle ⭐
By Default, the cutting shape is a polygon. You can change this to cut as a circle.
You can also enable Cut-Mode with a Circle like this:
map.pm.enableDraw("CutCircle");
If you use the toolbar, you can change the toolbar's cut-button behavior to use a circle instead of a polygon:
map.pm.setGlobalOptions({ cutAsCircle: true });