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
:
Method | Returns | Description |
---|---|---|
enableGlobalLassoMode() | - | Enables global Lasso Mode. |
disableGlobalLassoMode() | - | Disables global Lasso Mode. |
toggleGlobalLassoMode() | - | Toggles global Lasso Mode. |
globalLassoModeEnabled() | Boolean | Returns true if global Lasso Mode is enabled. false when disabled. |
The following events are available on a map instance:
Event | Params | Description | Output |
---|---|---|---|
gm:lasso | event | Fired during lasso selection. | map , features |
The following events are available on a map instance:
Event | Params | Description | Output |
---|---|---|---|
gm:globallassomodetoggled | event | Fired 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