Copy Mode
You can handle Copy Mode for all layers on a map like this:
map.gm.enableGlobalCopyMode();
map.gm.disableGlobalCopyMode();
map.gm.toggleGlobalCopyMode();
map.gm.globalCopyModeEnabled();
// Or like this:
map.gm.enableMode('edit', 'copy');
map.gm.disableMode('edit', 'copy');
map.gm.toggleMode('edit', 'copy');
map.gm.isModeEnabled('edit', 'copy');
The following methods are available on map.gm
:
Method | Returns | Description |
---|---|---|
enableGlobalCopyMode() | - | Enables global Copy Mode. |
disableGlobalCopyMode() | - | Disables global Copy Mode. |
toggleGlobalCopyMode() | - | Toggles global Copy Mode. |
globalCopyModeEnabled() | Boolean | Returns true if global Copy Mode is enabled. false when disabled. |
The following events are available on a map instance:
Event | Params | Description | Output |
---|---|---|---|
gm:copystart | event | Fired when a layer starts being copied. | map , feature , shape |
gm:copy | event | Fired when a layer is being copied. | map , feature , shape |
gm:copyend | event | Fired when a layer is copied. | map , feature , shape |
The following events are available on a map instance:
Event | Params | Description | Output |
---|---|---|---|
gm:globalcopymodetoggled | event | Fired when Copy Mode is toggled. | enabled , map |
You can also listen to specific Copy Mode events on the map instance like this:
map.on('gm:globalcopymodetoggled', (event) => {
console.log(event);
});
Behavior
Copy mode operates in two ways:
- Sticky Mode Enabled: A shape can be selected once and then copied multiple times on each subsequent click.
- Sticky Mode Disabled: A shape is copied when a user drags it to a new location.