Split Mode
Split Mode allows you to draw a line that splits all underlying Polygons and Lines. When a feature is split, the original feature will be replaced with the resulting split features.
You can handle Split Mode for all layers on a map like this:
map.gm.enableMode('edit', 'split');
map.gm.disableMode('edit', 'split');
map.gm.toggleMode('edit', 'split');
map.gm.isModeEnabled('edit', 'split');
The following methods are available on map.gm:
| Method | Returns | Description |
|---|---|---|
enableMode('edit', 'split') | - | Enables global Split Mode. |
disableMode('edit', 'split') | - | Disables global Split Mode. |
toggleMode('edit', 'split') | - | Toggles global Split Mode. |
isModeEnabled('edit', 'split') | Boolean | Returns true if global Split Mode is enabled. false when disabled. |
The following events are available on a map instance:
| Event | Params | Description | Output |
|---|---|---|---|
gm:split | event | Fired during the split operation. | map, originalFeature, features |
gm:create | event | Fired during the split operation. | map, feature, shape |
The following events are available on a map instance:
| Event | Params | Description | Output |
|---|---|---|---|
gm:globalsplitmodetoggled | event | Fired when Split Mode is toggled. | enabled, map |
You can also listen to specific Split Mode events on the map instance like this:
map.on('gm:globalsplitmodetoggled', (event) => {
console.log(event);
});
Behavior
Split mode operates by:
- Drawing a line across features you want to split
- The line will split any intersecting polygons or lines into separate features
- Original features are replaced with the resulting split features