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

Bug when drawing Polylines, Polygons #545

Closed pungiish closed 4 years ago

pungiish commented 4 years ago

Hey, I have a map with a lot of layers, features, etc. It's basically a very large GEOJSON file. When really zoomed in, I can start drawing Polylines/Polygons, but I can't finish them. The first point gets added normally, the 2nd point however, doesn't register, as if I wasn't clicking. So i checked with the 'click' event listener and clicking works correctly. I get stuck on 'Click to continue drawing'.

Drawing a rectangle, works, though. Again, this issue only appears when really zoomed in, but not when zoomed out. Any ideas why that could happen?

Cheers!

codeofsumit commented 4 years ago

@pungiish Hi Jan, Please create a jsfiddle so I can see the problem in action and help you out. The demo works fine for me.

Falke-Design commented 4 years ago

This only happens if the zoom is really high (tested with 50).

The problem with line is that L.LatLng.equals has a inaccuracy 1.0E-9 src and then it matches the first latlng and want to finish the line.

https://github.com/geoman-io/leaflet-geoman/blob/9f3cecdc0b5cbd029bf5ea1916ea26f188bcda5e/src/js/Draw/L.PM.Draw.Line.js#L267

https://jsfiddle.net/falkedesign/u4cf3pnh/

This can be fixed when we passing a margin latlng.equals(this._layer.getLatLngs()[0], 1.0E-14).

BUT I don't know if this is good, because no other geoman tool is working well on this zoom lvl and leaflet self has also problems with that.

Falke-Design commented 4 years ago

Close #545 because this will not supported in the next future