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

Clicking on the first point doesn't close the Polyline/Polygon shape

Open gholol opened this issue 8 years ago • 13 comments

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

  1. Go to https://leaflet.github.io/Leaflet.draw/docs/examples/full.html

  2. Click on "Draw Polyline"

  3. Draw some lines

  4. Click on the first point to close the shape.

gholol avatar Dec 16 '16 21:12 gholol

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 avatar Dec 17 '16 12:12 andrewvink

@andrewvink I can confirm that #657 fixes this issue.

gholol avatar Dec 17 '16 12:12 gholol

@gholol Awesome, thanks - works perfectly :)

andrewvink avatar Dec 17 '16 13:12 andrewvink

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

Candyffm avatar Mar 15 '20 22:03 Candyffm

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

johnd0e avatar Mar 19 '20 13:03 johnd0e

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 avatar Mar 25 '20 07:03 Candyffm

@Candyffm tap is map option.

Try this: https://jsfiddle.net/johnd0e/pLrad09w/

johnd0e avatar Mar 25 '20 10:03 johnd0e

@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.

Candyffm avatar Mar 25 '20 11:03 Candyffm

doesn't allow clicking on the first point's handle

first is for polygon. To finish polyline you have to click last handle.

johnd0e avatar Mar 25 '20 12:03 johnd0e

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.

Candyffm avatar Mar 25 '20 13:03 Candyffm

I accept this as a lack of functionality of this library.

Ok, then better open separate issue for that

johnd0e avatar Mar 25 '20 14:03 johnd0e

It is still exists in 6/2023

robozb avatar Jul 02 '23 00:07 robozb

still exist on 2024/05/13

iamtekson avatar May 13 '24 20:05 iamtekson