Line Simplification Mode
Line Simplification Mode allows you to simplify line geometry by removing vertices. This is useful for smoothing complex lines or reducing the number of points in a line.
You can handle Line Simplification Mode for all layers on a map like this:
map.gm.enableGlobalLineSimplificationMode();
map.gm.disableGlobalLineSimplificationMode();
map.gm.toggleGlobalLineSimplificationMode();
map.gm.globalLineSimplificationModeEnabled();
// Or like this:
map.gm.enableMode('edit', 'line_simplification');
map.gm.disableMode('edit', 'line_simplification');
map.gm.toggleMode('edit', 'line_simplification');
map.gm.isModeEnabled('edit', 'line_simplification');
The following methods are available on map.gm
:
Method | Returns | Description |
---|---|---|
enableGlobalLineSimplificationMode() | - | Enables global Line Simplification Mode. |
disableGlobalLineSimplificationMode() | - | Disables global Line Simplification Mode. |
toggleGlobalLineSimplificationMode() | - | Toggles global Line Simplification Mode. |
globalLineSimplificationModeEnabled() | Boolean | Returns true if global Line Simplification Mode is enabled. false when disabled. |
The following events are available on a map instance:
Event | Params | Description | Output |
---|---|---|---|
gm:line_simplification | event | Fired during simplification. | map , feature , shape |
The following events are available on a map instance:
Event | Params | Description | Output |
---|---|---|---|
gm:globallinesimplificationmodetoggled | event | Fired when Line Simplification Mode is toggled. | enabled , map |
You can also listen to specific Line Simplification Mode events on the map instance like this:
map.on('gm:globalline_simplificationmodetoggled', (event) => {
console.log(event);
});
Behavior
Line Simplification mode operates by:
- Selecting a line feature to simplify
- Clicking on vertices you want to remove from the line
- The line geometry will be updated with the selected vertices removed
Supported Shapes
Line Simplification mode supports the following feature types:
- Lines
- Polygons