Leaflet.draw icon indicating copy to clipboard operation
Leaflet.draw copied to clipboard

Zooming in or out while drawing a polygon incorrectly adds points to the polygon

Open joelryan2k opened this issue 7 years ago • 2 comments

  • [x] I'm reporting a bug, not asking for help
  • [x] I've looked at the documentation to make sure the behaviour is documented and expected
  • [x] I'm sure this is a Leaflet Draw code issue, not an issue with my own code nor with the framework I'm using (Cordova, Ionic, Angular, React…)
  • [x] I've searched through the issues to make sure it's not yet reported

How to reproduce

  • Leaflet version I'm using: 1.0.1
  • Leaflet Draw version I'm using: 0.4.2
  • Browser (with version) I'm using: Chrome 55.0.2883.95
  • OS/Platform (with version) I'm using: MacOS 10.12.5
    1. Go to https://leaflet.github.io/Leaflet.draw/docs/examples/full.html
    1. Start drawing a polygon, draw a single point
    1. Click zoom out

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

I would expect that the map would zoom out but a second point on the polygon would not be added

Instead a second point is added to the polygon, which I did not intend. The same thing happens when I zoom in.

Minimal example reproducing the issue

It's fully demonstrable in the stock example: https://leaflet.github.io/Leaflet.draw/docs/examples/full.html

  • [x] this example is as simple as possible
  • [x] this example does not rely on any third party code

joelryan2k avatar Jun 13 '17 02:06 joelryan2k

It looks like the _onTouch of Polyline calls the _startPoint and _endPoint functions one after the other. This pretty much simulates a MouseDown and MouseUp when a person touches down. By doing this, it immediately places a vertex, without knowing whether the user is panning or zooming.

I commented out _endPoint call inside of _onTouch and let the _onMouseUp call _endPoint. Now, panning and zooming works without dropping a vertex. Whoever is in charge of this bug needs to ensure this doesn't break other functionality on other browsers and devices.

However, this does not fix the issue where you click the zoom control button on the leaflet map and it drops a vertex underneath the + or -.

jmanghani avatar Nov 30 '17 20:11 jmanghani

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

johnd0e avatar Jan 24 '20 13:01 johnd0e