Skip to main content

Drag Mode

Drag Mode

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

// enable Drag Mode like this:
map.pm.enableGlobalDragMode();

Or you enable dragging for a specific layer:

layer.pm.enableLayerDrag();

The following methods are available on layer.pm:

MethodReturnsDescription
enableLayerDrag()-Enables dragging for the layer.
disableLayerDrag()-Disables dragging for the layer.
layerDragEnabled()BooleanReturns if Drag Mode is enabled for the layer.
dragging()BooleanReturns if the layer is currently dragging.

The following methods are available on map.pm:

MethodReturnsDescription
enableGlobalDragMode()-Enables global Drag Mode.
disableGlobalDragMode()-Disables global Drag Mode.
toggleGlobalDragMode()-Toggles global Drag Mode.
globalDragModeEnabled()BooleanReturns true if global Drag Mode is enabled. false when disabled.

The following events are available on a layer instance:

EventParamsDescriptionOutput
pm:dragstarteFired when a layer starts being dragged.layer, shape
pm:drageFired when a layer is dragged.layer, containerPoint,latlng, layerPoint,originalEvent, shape
pm:dragendeFired when a layer stops being dragged.layer, shape
pm:dragenableeFired when Drag Mode on a layer is enabled.layer, shape
pm:dragdisableeFired when Drag Mode on a layer is disabled.layer, shape
pm:changeeFired coordinates of the layer changed.layer, latlngs, shape

The following events are available on a map instance:

EventParamsDescriptionOutput
pm:globaldragmodetoggledeFired when Drag Mode is toggled.enabled, map

You can also listen to specific Drag Mode events on the map instance like this:

map.on("pm:globaldragmodetoggled", (e) => {
console.log(e);
});

Example

Loading...