Skip to main content

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.enableGlobalUnionMode();
map.gm.disableGlobalUnionMode();
map.gm.toggleGlobalUnionMode();
map.gm.globalUnionModeEnabled();

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

MethodReturnsDescription
enableGlobalUnionMode()-Enables global Union Mode.
disableGlobalUnionMode()-Disables global Union Mode.
toggleGlobalUnionMode()-Toggles global Union Mode.
globalUnionModeEnabled()BooleanReturns true if global Union Mode is enabled. false when disabled.

The following events are available on a map instance:

EventParamsDescriptionOutput
gm:unioneventFired during the union operation.map, originalFeatures, feature
gm:createeventFired during the union operation.map, feature, shape

The following events are available on a map instance:

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

  1. Selecting multiple polygons to merge
  2. The selected polygons will be combined into a single polygon
  3. Original features are replaced with the resulting union feature

Supported Shapes

Union mode supports the following feature types:

  • Polygons
  • Rectangles
  • Circles

Live Union Example