Copy Layer Mode ⭐
Copy Layer Mode ⭐
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
:
Method | Returns | Description |
---|---|---|
enableGlobalCopyLayerMode() | - | Enables global Copy Layer Mode. |
disableGlobalCopyLayerMode() | - | Disables global Copy Layer Mode. |
toggleGlobalCopyLayerMode() | - | Toggles global Copy Layer Mode. |
globalCopyLayerModeEnabled() | Boolean | Returns true if global Copy Layer Mode is enabled. false when disabled. |
The following events are available on a map instance:
Event | Params | Description | Output |
---|---|---|---|
pm:globalcopylayermodetoggled | e | Fired when Copy Layer is toggled. | enabled , map |
pm:copylayer | e | Fired 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,
});