Skip to main content

Copy Mode

You can handle Copy Mode for all layers on a map 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:

MethodReturnsDescription
enableMode('edit', 'copy')-Enables global Copy Mode.
disableMode('edit', 'copy')-Disables global Copy Mode.
toggleMode('edit', 'copy')-Toggles global Copy Mode.
isModeEnabled('edit', 'copy')BooleanReturns true if global Copy Mode is enabled. false when disabled.

The following events are available on a map instance:

EventParamsDescriptionOutput
gm:copystarteventFired when a layer starts being copied.map, feature, shape
gm:copyeventFired when a layer is being copied.map, feature, shape
gm:copyendeventFired when a layer is copied.map, feature, shape

The following events are available on a map instance:

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

  1. Sticky Mode Enabled: A shape can be selected once and then copied multiple times on each subsequent click.
  2. Sticky Mode Disabled: A shape is copied when a user drags it to a new location.

Live Copy Example