geoman-io / leaflet-geoman

🍂🗺️ The most powerful leaflet plugin for drawing and editing geometry layers
https://geoman.io
MIT License
2.21k stars 433 forks source link

When both Draw and Edit are simultaneously enabled, a few problems occur. #1031

Open EliezerB123 opened 2 years ago

EliezerB123 commented 2 years ago

Hello! It's me again. This library is really, really good. But.... I've noticed two issues when attempting to have both Draw and Edit active simultaneously. JsFiddle: https://jsfiddle.net/e8fcduyg/1/ I'm not sure if this is something you will fix, because users can fix it themselves and it's a niche case. (I've fixed these in my projects using rather messy hacks.) But anyway, I thought I ought to mention it.

Issue one: When both Draw and Edit are simultaneously active, when dragging a vertex and snapping it to another vertex, the user accidentally starts drawing.

To reproduce: 1a. Enable snap. 1b. Enable drawing of Polyline. 1c. Enable Editing. 1d. Draw two Polylines. 1e. Drag one line and snap it to the other line. Notice that when you do, Geoman automatically starts drawing a new line. (because there's no vertex underneath the cursor when you let go of the vertex?)

Expected behavior: Once I start dragging a vertex, drawing should be disabled until I finish dragging it.


Issue two: When both Draw and Edit are simultaneously active, the user can't draw a line to a pre-existing vertex. If he tries to draw a line to that location, the marker is dragged instead.

To reproduce:

2a. Enable snap. 2b. Enable drawing of Polyline. 2c. Enable Editing. 2d. Draw a Polyline. 2e. Draw another polyline, and attempt to draw to one of the vertexes belonging to the first line. Notice that we can't, because when we click on a vertex, it attempts to drag instead of drawing.

Expected behavior: When both drawing and editing are active, once a user has started drawing and added his first vertex, dragging should be disabled until the user finishes drawing his current line. If a user clicks on a vertex, we should draw to that location.

JsFiddle (For both): https://jsfiddle.net/e8fcduyg/1/

Falke-Design commented 2 years ago

We currently not support the use of both modes togheter. I'm very suprised that it works so good.

I've fixed these in my projects using rather messy hacks.

What have you changed? Would be interessting if we decide to implement this in future. Until then please upvote the existing Feature Request: #317

sbahr001 commented 2 years ago

@EliezerB123 is it possible to share your messy hacks?

I am working on a project where I am expected to add a similar feature and it would save me some time. :). Thank you for the current share :)

EliezerB123 commented 2 years ago

@EliezerB123 is it possible to share your messy hacks?

I am working on a project where I am expected to add a similar feature and it would save me some time. :). Thank you for the current share :)

@sbahr001 Sorry, I can't share the code for... reasons, but I assure you, you're not missing out. The hack was really, really messy.

sbahr001 commented 2 years ago

Haha, thank you anyway. 😄