Split Mode ⭐
Split Mode ⭐

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:
| Option | Default | Description |
|---|---|---|
| splitOnlyMarkedLayers | false | If 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:
| Method | Returns | Description |
|---|---|---|
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() | Boolean | Returns true if global Split Mode is enabled. false when disabled. |
The following events are available on a layer instance:
| Event | Params | Description | Output |
|---|---|---|---|
| pm:split | e | Fired 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:
| Event | Params | Description | Output |
|---|---|---|---|
| pm:globalsplitmodetoggled | e | Fired when Split Mode is toggled. | enabled, map |
| pm:split | e | Fired when any layer is being split. | shape, splitLayer, layers, originalLayer |
Example
Loading...