Union Mode
Union Mode allows you to merge multiple polygons into a single polygon. The original features will be replaced with the resulting union feature.
You can handle Union Mode for all layers on a map like this:
map.gm.enableMode('edit', 'union');
map.gm.disableMode('edit', 'union');
map.gm.toggleMode('edit', 'union');
map.gm.isModeEnabled('edit', 'union');
The following methods are available on map.gm:
| Method | Returns | Description |
|---|---|---|
enableMode('edit', 'union') | - | Enables global Union Mode. |
disableMode('edit', 'union') | - | Disables global Union Mode. |
toggleMode('edit', 'union') | - | Toggles global Union Mode. |
isModeEnabled('edit', 'union') | Boolean | Returns true if global Union Mode is enabled. false when disabled. |
The following events are available on a map instance:
| Event | Params | Description | Output |
|---|---|---|---|
gm:union | event | Fired during the union operation. | map, originalFeatures, feature |
gm:create | event | Fired during the union operation. | map, feature, shape |
The following events are available on a map instance:
| Event | Params | Description | Output |
|---|---|---|---|
gm:globalunionmodetoggled | event | Fired when Union Mode is toggled. | enabled, map |
You can also listen to specific Union Mode events on the map instance like this:
map.on('gm:globalunionmodetoggled', (event) => {
console.log(event);
});
Behavior
Union mode operates by:
- Selecting multiple polygons to merge
- The selected polygons will be combined into a single polygon
- Original features are replaced with the resulting union feature
Supported Shapes
Union mode supports the following feature types:
- Polygons
- Rectangles
- Circles