Skip to main content

Line Simplification Mode ⭐

Line Simplification Mode ⭐

Line Simplification Feature

You can enable Line Simplification Mode for all layers on a map like this:

map.pm.enableGlobalLineSimplificationMode();

Leaflet-Geoman's Line Simplification Mode enables easy and efficient simplification of line and polygon geometry. Users select a layer, click the starting vertex to begin, and preview the points that will be removed. After clicking the ending vertex, the layer is updated with the simplified geometry.

The following methods are available on map.pm:

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
pm:globallinesimplificationmodetoggledeFired when Line Simplification Mode is toggled.enabled, map
pm:linesimplificationeFired when a new layer is created by copying an existing layer.sourceLayer, newLayer, shape

Line Simplification Mode Button in the Toolbar

You can also enable/disable a button in the toolbar to toggle Line Simplification mode. You can enable (disable) it by setting lineSimplificationMode to true (false) in the addControls options.

map.pm.addControls({ 
lineSimplificationMode: true,
});

Examples

Loading...