Skip to main content

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:

MethodReturnsDescription
enableGlobalLineSimplificationMode()-Enables global Line Simplification Mode.
disableGlobalLineSimplificationMode()-Disables global Line Simplification Mode.
toggleGlobalLineSimplificationMode()-Toggles global Line Simplification Mode.
globalLineSimplificationModeEnabled()BooleanReturns true if global Line Simplification Mode is enabled. false when disabled.

The following events are available on a map instance:

EventParamsDescriptionOutput
gm:line_simplificationeventFired during simplification.map, feature, shape

The following events are available on a map instance:

EventParamsDescriptionOutput
gm:globallinesimplificationmodetoggledeventFired 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:

  1. Selecting a line feature to simplify
  2. Clicking on vertices you want to remove from the line
  3. The line geometry will be updated with the selected vertices removed

Supported Shapes

Line Simplification mode supports the following feature types:

  • Lines
  • Polygons

Live Line Simplification Example