Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow removal of holes in polygons while maintaining the minimum vertex count of the geometry #1475

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/js/Edit/L.PM.Edit.Line.js
Original file line number Diff line number Diff line change
Expand Up @@ -473,8 +473,12 @@ Edit.Line = Edit.extend({
let markerArr =
indexPath.length > 1 ? get(this._markers, parentPath) : this._markers;

// prevent removal of the layer if the vertex count is below minimum
if (!this.options.removeLayerBelowMinVertexCount) {
// define whether marker is part of hole
const isHole =
parentPath[parentPath.length - 1] > 0 && this._layer instanceof L.Polygon;

// prevent removal of the layer if the vertex count is below minimum when not a hole
if (!this.options.removeLayerBelowMinVertexCount && !isHole) {
// if on a line only 2 vertices left or on a polygon 3 vertices left, don't allow to delete
if (
coordsRing.length <= 2 ||
Expand Down