Difference Mode ⭐
Difference Mode ⭐
You can enable Difference Mode for all layers on a map like this:
map.pm.enableGlobalDifferenceMode();
The difference mode in Leaflet-Geoman allows users to subtract one leaflet layer from another. This mode can be enabled programmatically or through the provided toolbar. It supports subtracting polygons (or multipolygons). The difference mode simplifies separating geometries. The difference mode works by selecting two layers to differentiate, then the difference mode will create a new layer that represents the difference between the two selected layers. The new layer will be added to the map and the two selected layers will be removed from the map.
The following methods are available on map.pm
:
Method | Returns | Description |
---|---|---|
enableGlobalDifferenceMode() | - | Enables global Difference Mode. |
disableGlobalDifferenceMode() | - | Disables global Difference Mode. |
toggleGlobalDifferenceMode() | - | Toggles global Difference Mode. |
globalDifferenceModeEnabled() | Boolean | Returns true if global Difference Mode is enabled. false when disabled. |
The following events are available on a map instance:
Event | Params | Description | Output |
---|---|---|---|
pm:globaldifferencemodetoggled | e | Fired when Difference Mode is toggled. | enabled , map |
pm:difference | e | Fired when a new layer is created by difference of two other layers. | resultLayer , subtractedLayers |
Example
Loading...