Skip to main content

Copy Layer Mode ⭐

Copy Layer Mode ⭐

Copy Layer Feature

You can enable Copy Layer Mode for all layers on a map like this:

map.pm.enableGlobalCopyLayerMode();

The copy mode in Leaflet-Geoman allows users to create a copy of an existing layer. This mode can be enabled programmatically or through the provided toolbar. It supports copying points, lines and polygons (or multipolygons). The copy mode simplifies creating a copy of a layer. The copy mode works by selecting a layer to copy, then the copy mode will create a new layer that represents the copy of the selected layer. New layers can then be added to the map by clicking at the desired locations.

The following methods are available on map.pm:

MethodReturnsDescription
enableGlobalCopyLayerMode()-Enables global Copy Layer Mode.
disableGlobalCopyLayerMode()-Disables global Copy Layer Mode.
toggleGlobalCopyLayerMode()-Toggles global Copy Layer Mode.
globalCopyLayerModeEnabled()BooleanReturns true if global Copy Layer Mode is enabled. false when disabled.

The following events are available on a map instance:

EventParamsDescriptionOutput
pm:globalcopylayermodetoggledeFired when Copy Layer is toggled.enabled, map
pm:copylayereFired when a new layer is created by copying an existing layer.sourceLayer, newLayer, shape

Copy Layer Mode Button in the Toolbar

You can also enable/disable a button in the toolbar to toggle copy layer mode. You can enable (disable) it by setting copyLayerMode to true (false) in the addControls options.

map.pm.addControls({ 
copyLayerMode: true,
});
Loading...