Skip to main content

Split Mode ⭐

Split Mode ⭐

Split Mode Demo

Enable drawing for the shape "Split" to draw a line that splits all underlying Polygons and Polylines.

Important: the splitted layer will be replaced, not updated. Listen to the pm:split event to update your layer references in your code. The pm:split 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.enableGlobalSplitMode({
allowSelfIntersection: false,
});

Available options are the same as in Draw Mode and in table below:

OptionDefaultDescription
splitOnlyMarkedLayersfalseIf it is set to false layers can be excluded with the option splitMark: false. Set it to true to enable splitting only for the layers with the option splitMark: true.

The following methods are available on map.pm:

MethodReturnsDescription
enableGlobalSplitMode(options)-Enable Split Mode. View Options (same as Edit Mode)
disableGlobalSplitMode()-Disable Split Mode.
toggleGlobalSplitMode(options)-Toggle Split Mode. View Options (same as Edit Mode)
globalSplitModeEnabled()BooleanReturns true if global Split Mode is enabled. false when disabled.

The following events are available on a layer instance:

EventParamsDescriptionOutput
pm:spliteFired when the layer being split. Returns a LayerGroup containing all resulting layers in layers.shape, splitLayer, layers, originalLayer

The following events are available on a map instance:

EventParamsDescriptionOutput
pm:globalsplitmodetoggledeFired when Split Mode is toggled.enabled, map
pm:spliteFired when any layer is being split.shape, splitLayer, layers, originalLayer