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
:
Method | Returns | Description |
---|---|---|
enableGlobalCutMode() | - | Enables global Cut Mode. |
disableGlobalCutMode() | - | Disables global Cut Mode. |
toggleGlobalCutMode() | - | Toggles global Cut Mode. |
globalCutModeEnabled() | Boolean | Returns true if global Cut Mode is enabled. false when disabled. |
The following events are available on a map instance:
Event | Params | Description | Output |
---|---|---|---|
gm:cutstart | event | Fired when a cut operation starts. | map , feature , shape |
gm:cut | event | Fired during the cut operation. | map , feature , shape |
gm:cutend | event | Fired when a cut operation is completed. | map , feature , shape |
The following events are available on a map instance:
Event | Params | Description | Output |
---|---|---|---|
gm:globalcutmodetoggled | event | Fired 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:
- Selecting a target shape to cut
- Drawing a polygon that defines the area to be removed
- The intersection of the drawn polygon with the target shape will be removed