Skip to main content

Lasso Mode

Lasso Mode allows you to select multiple features by drawing a polygon around them. The selection behavior can be configured to either select features that intersect with or are contained within the lasso polygon.

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

map.gm.enableGlobalLassoMode();
map.gm.disableGlobalLassoMode();
map.gm.toggleGlobalLassoMode();
map.gm.globalLassoModeEnabled();

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

The following methods are available on map.gm:

MethodReturnsDescription
enableGlobalLassoMode()-Enables global Lasso Mode.
disableGlobalLassoMode()-Disables global Lasso Mode.
toggleGlobalLassoMode()-Toggles global Lasso Mode.
globalLassoModeEnabled()BooleanReturns true if global Lasso Mode is enabled. false when disabled.

The following events are available on a map instance:

EventParamsDescriptionOutput
gm:lassoeventFired during lasso selection.map, features

The following events are available on a map instance:

EventParamsDescriptionOutput
gm:globallassomodetoggledeventFired when Lasso Mode is toggled.enabled, map

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

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

Behavior

Lasso mode operates in three selection modes:

  • Append: Add selected features to the current selection
  • Subtract: Remove selected features from the current selection
  • Reset: Clear current selection and create a new selection

The selection type can be configured to either:

  • Intersects: Select features that intersect with the lasso polygon
  • Contains: Select only features that are completely contained within the lasso polygon

Live Lasso Example