Skip to main content

Drag Mode

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

map.gm.enableGlobalDragMode();
map.gm.disableGlobalDragMode();
map.gm.toggleGlobalDragMode();
map.gm.globalDragModeEnabled();

// Or like this:
map.gm.enableMode('edit', 'drag');
map.gm.disableMode('edit', 'drag');
map.gm.toggleMode('edit', 'drag');
map.gm.isModeEnabled('edit', 'drag');

The following methods are available on map.gm:

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 map instance:

EventParamsDescriptionOutput
gm:dragstarteventFired when a layer starts being dragged.map, feature, shape
gm:drageventFired when a layer is dragged.map, feature, shape
gm:dragendeventFired when a layer stops being dragged.map, feature, shape

The following events are available on a map instance:

EventParamsDescriptionOutput
gm:globaldragmodetoggledeventFired when Drag Mode is toggled.enabled, map

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

map.on('gm:globaldragmodetoggled', (event) => {
console.log(event);
});

Live Drag Example