Skip to main content

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.enableGlobalSplitMode();
map.gm.disableGlobalSplitMode();
map.gm.toggleGlobalSplitMode();
map.gm.globalSplitModeEnabled();

// Or 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:

MethodReturnsDescription
enableGlobalSplitMode()-Enables global Split Mode.
disableGlobalSplitMode()-Disables global Split Mode.
toggleGlobalSplitMode()-Toggles global Split Mode.
globalSplitModeEnabled()BooleanReturns true if global Split Mode is enabled. false when disabled.

The following events are available on a map instance:

EventParamsDescriptionOutput
gm:spliteventFired during the split operation.map, originalFeature, features
gm:createeventFired during the split operation.map, feature, shape

The following events are available on a map instance:

EventParamsDescriptionOutput
gm:globalsplitmodetoggledeventFired 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:

  1. Drawing a line across features you want to split
  2. The line will split any intersecting polygons or lines into separate features
  3. Original features are replaced with the resulting split features

Live Split Example