Leaflet.draw
Leaflet.draw copied to clipboard
Clicking on the first point doesn't close the Polyline/Polygon shape
Clicking on the first point doesn't close the Polyline/Polygon shape, unless you click on the "Finish" button.
Same thing happens on my own app when I try to use draw handlers only. The shape just won't close.
How to reproduce
- Leaflet version I'm using: 1.0.1
- Leaflet Draw version I'm using: 0.4.7
- Browser (with version) I'm using: Chrome 55
- OS/Platform (with version) I'm using: Windows 10
What behaviour I'm expecting and which behaviour I'm seeing
Closed shape
Minimal example reproducing the issue
-
Go to https://leaflet.github.io/Leaflet.draw/docs/examples/full.html
-
Click on "Draw Polyline"
-
Draw some lines
-
Click on the first point to close the shape.
Also Experiencing this bug:
- Leaflet: Version 1.0.1
- Leaflet Draw: Version 0.4.7
- Browser: Version 55.0.2883.87 m (64-bit)
- OS: Windows 7 (64-bit)
@andrewvink I can confirm that #657 fixes this issue.
@gholol Awesome, thanks - works perfectly :)
Polylines are not closeable, its not even possible to add another point close to another point.
Leaflet version I'm using: 1.6.0 Leaflet Draw version I'm using: 1.0.3 Browser (with version) I'm using: Chrome 80 OS/Platform (with version) I'm using: Windows 10
Polylines are not closeable, its not even possible to add another point close to another point.
I do not have issues with specified versions. Could you provide sample?
It's also useful:
- specify
{tap: false}map option. - apply this fix https://github.com/Leaflet/Leaflet.draw/issues/695#issuecomment-577151966
https://jsfiddle.net/Candyffm/s7vhgmkf/22/
Try to draw a polyline that ends at the starting point (or very close to it). The start point handle catches the click event. I tried both of the potential fixes / workarounds you listed without a change.
@Candyffm
tap is map option.
Try this: https://jsfiddle.net/johnd0e/pLrad09w/
@johnd0e
first of all: thanks for your quick replies.
The tap option was a copy/paste leftover that made it into the fiddle. It tried it as a map option before, just like it is done in your fiddle. But still, your fiddle - just like mine - doesn't allow clicking on the first point's handle to close/end the route. I checked it in the latest Chrome, Firefox, Edge and IE11. In Firefox it is even more dominant due to the bigger handles.
doesn't allow clicking on the first point's handle
first is for polygon. To finish polyline you have to click last handle.
I know, but this topic is about closing polygons and polylines by clicking on the first point (literally). Polygons are not the problem, but not being able to finish a polyline can be a problem in certain cases e.g. drawing hiking round routes. Technically speaking the polyline then becomes a polygon but forcing a user to choose between a polyline and a polygon is not a user friendly option and you loose too much flexibility when editing the route.
I accept this as a lack of functionality of this library. I just wanted to update this issue as the previous answers indicated that there is a fix for this behaviour.
I accept this as a lack of functionality of this library.
Ok, then better open separate issue for that
It is still exists in 6/2023
still exist on 2024/05/13