Leaflet / Leaflet.draw

Vector drawing and editing plugin for Leaflet
https://leaflet.github.io/Leaflet.draw/docs/leaflet-draw-latest.html
MIT License
1.97k stars 992 forks source link

Double clicking on touch browsers creates multiple nodes and difficulties in editing or finalising polygon due to "Shape edges cannot cross" error #712

Open mdomnita opened 7 years ago

mdomnita commented 7 years ago

How to reproduce

In the main example, using a touch enabled browser (Chrome) and a desktop computer, start drawing a polygon. Double clicking on a point does not close the polygon (like it does in Firefox). Instead it zooms in and moves the map giving the user difficulty in continuing the polygon creation. If the mouse is moved by mistake when double clicking, new vertexes are created and the user easily gets to the situation where he has multiple vertices on top of one another and is not able to continue the polygon because of the "Shape edges cannot cross" error.

What behaviour I'm expecting and which behaviour I'm seeing

A new node should not be added unless there is a minimal distance between the last node and the new one (the mouse is out of the square marking the last node). If the user tries to create a new node it should snap to the current one. Double clicking should close the polygon on all browsers on desktop computers.

Minimal example reproducing the issue

The main example on the page causes the same issues like I get with the new versions of Leaflet and Leaflet.draw. http://leaflet.github.io/Leaflet.draw/docs/examples/full.html A video of the behavior can be seen here https://youtu.be/sCnKx9zOD5c

Disabling the touch from Javascript would cause problems on mobile devices and I expect them both to work.

Using jsfiddle or another example site.

hanginwithdaddo commented 7 years ago

Drawing a rectangle using a drag motion also has problems.

torsture commented 7 years ago

Nice issue report, the issue also occurs in Edge on Windows 10.

There is also an issue when polygon drawing is enabled and the user drags the map a new vertex is added.

adearmas8 commented 7 years ago

anyone find a fix for this issue?

johnd0e commented 4 years ago

Possible fix: https://github.com/Leaflet/Leaflet.draw/issues/935#issuecomment-577151194