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
:
Method | Returns | Description |
---|---|---|
enableGlobalRemovalMode() | - | Enables global Remove Mode. |
disableGlobalRemovalMode() | - | Disables global Remove Mode. |
toggleGlobalRemovalMode() | - | Toggles global Remove Mode. |
globalRemovalModeEnabled() | Boolean | Returns true if global Remove Mode is enabled. false when disabled. |
The following events are available on a map instance:
Event | Params | Description | Output |
---|---|---|---|
gm:remove | event | Fired when a feature is removed. | map , feature , shape |
The following events are available on a map instance:
Event | Params | Description | Output |
---|---|---|---|
gm:globalremovalmodetoggled | event | Fired 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:
- Clicking on a feature to remove it from the map
- The feature and all its associated markers will be deleted immediately
- The removal cannot be undone