Skip to main content

Explode Mode

explode splits a multipolygon into separate single-polygon features. It is a selection-gated mode and only applies to multipolygons — select a multipolygon first (see Select Mode) and the Explode control becomes enabled. The control stays disabled for a plain Polygon, since there is nothing to split (requiresSelection context multipolygon).

When a multipolygon is exploded, the original feature is removed (gm:remove) and one new feature is created per part (gm:create).

map.gm.enableMode('edit', 'explode');
map.gm.disableMode('edit', 'explode');
map.gm.toggleMode('edit', 'explode');
map.gm.isModeEnabled('edit', 'explode');

Programmatic API

const result = await map.gm.edit.explode('subedit-polygon');

if (result.ok) {
console.log('New features:', result.features); // one per part
} else {
console.warn('Rejected:', result.reason); // e.g. 'no_target'
}

The following methods are available on map.gm:

MethodReturnsDescription
enableMode('edit', 'explode')PromiseEnables Explode Mode.
disableMode('edit', 'explode')PromiseDisables Explode Mode.
toggleMode('edit', 'explode')PromiseToggles Explode Mode.
isModeEnabled('edit', 'explode')BooleanReturns true if Explode Mode is enabled. false when disabled.

The following events are available on a map instance:

EventParamsDescriptionOutput
gm:explodeeventFired when a multipolygon is exploded.map, features, shape
gm:createeventFired for each new single-polygon feature created.map, feature, shape
gm:removeeventFired when the original multipolygon is removed.map, feature, shape
map.on('gm:explode', (event) => {
console.log('Exploded into:', event.features?.map((f) => f.id));
});

Live Explode Example

This feature is a two-part multipolygon. Click it to select it, then activate Explode to split it into two independent polygons.

Building something complex? Our team can help with architecture and integration. Get in touch →