Skip to main content

Cut Mode

Cut Mode

cut polygon

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:

MethodReturnsDescription
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()BooleanReturns true if global cut mode is enabled. false when disabled.

The following events are available on a layer instance:

EventParamsDescriptionOutput
pm:cuteFired when the layer being cut.shape, layer, originalLayer
pm:editeFired when a layer is edited / cut.layer, shape

The following events are available on a map instance:

EventParamsDescriptionOutput
pm:globalcutmodetoggledeFired when Cut Mode is toggled.enabled, map
pm:cuteFired 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 });

Example

Loading...