Skip to main content

Remove Mode

Remove Mode allows you to delete features from the map by clicking on them.

You can handle Remove Mode for all layers on a map like this:

map.gm.enableGlobalRemovalMode();
map.gm.disableGlobalRemovalMode();
map.gm.toggleGlobalRemovalMode();
map.gm.globalRemovalModeEnabled();

// Or like this:
map.gm.enableMode('edit', 'delete');
map.gm.disableMode('edit', 'delete');
map.gm.toggleMode('edit', 'delete');
map.gm.isModeEnabled('edit', 'delete');

The following methods are available on map.gm:

MethodReturnsDescription
enableGlobalRemovalMode()-Enables global Remove Mode.
disableGlobalRemovalMode()-Disables global Remove Mode.
toggleGlobalRemovalMode()-Toggles global Remove Mode.
globalRemovalModeEnabled()BooleanReturns true if global Remove Mode is enabled. false when disabled.

The following events are available on a map instance:

EventParamsDescriptionOutput
gm:removeeventFired when a feature is removed.map, feature, shape

The following events are available on a map instance:

EventParamsDescriptionOutput
gm:globalremovalmodetoggledeventFired when Remove Mode is toggled.enabled, map

You can also listen to specific Remove Mode events on the map instance like this:

map.on('gm:globalremovalmodetoggled', (event) => {
console.log(event);
});

Behavior

Remove mode operates by:

  1. Clicking on a feature to remove it from the map
  2. The feature and all its associated markers will be deleted immediately
  3. The removal cannot be undone

Live Remove Example