Skip to main content

Cut Mode

Cut mode allows you to cut holes in existing shapes or remove parts of them. You can handle Cut Mode for all layers on a map like this:

map.gm.enableGlobalCutMode();
map.gm.disableGlobalCutMode();
map.gm.toggleGlobalCutMode();
map.gm.globalCutModeEnabled();

// Or like this:
map.gm.enableMode('edit', 'cut');
map.gm.disableMode('edit', 'cut');
map.gm.toggleMode('edit', 'cut');
map.gm.isModeEnabled('edit', 'cut');

The following methods are available on map.gm:

MethodReturnsDescription
enableGlobalCutMode()-Enables global Cut Mode.
disableGlobalCutMode()-Disables global Cut Mode.
toggleGlobalCutMode()-Toggles global Cut Mode.
globalCutModeEnabled()BooleanReturns true if global Cut Mode is enabled. false when disabled.

The following events are available on a map instance:

EventParamsDescriptionOutput
gm:cutstarteventFired when a cut operation starts.map, feature, shape
gm:cuteventFired during the cut operation.map, feature, shape
gm:cutendeventFired when a cut operation is completed.map, feature, shape

The following events are available on a map instance:

EventParamsDescriptionOutput
gm:globalcutmodetoggledeventFired when Cut Mode is toggled.enabled, map

You can also listen to specific Cut Mode events on the map instance like this:

map.on('gm:globalcutmodetoggled', (event) => {
console.log(event);
});

Behavior

The Cut Mode operates by:

  1. Selecting a target shape to cut
  2. Drawing a polygon that defines the area to be removed
  3. The intersection of the drawn polygon with the target shape will be removed

Live Cut Example