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

Add posibility to append new point to existing line

Open der-On opened this issue 11 years ago • 13 comments

It should be possible to append new points to an already existing line.

der-On avatar Apr 28 '14 20:04 der-On

When your line is in edit mode, dragging on a midpoint marker (between nodes) and then dropping it will effectively create two new midpoint markers and convert the dragged midpoint marker into a node. You can repeat this ad-infinitum to create as many new points as you might wish. Before: image After: image

peterb-2795 avatar Apr 29 '14 00:04 peterb-2795

Thank you. I know this feature and use it extensively however I find it more "natural" to append new points to the end of the line. Currently I have to drag a point near where I want my polyline to end and then create the nessecary points in between. The main problem I see here is that one can edit all existing features at once while in "edit" mode and thus it's hard to tell at which polyline the user want's to add new endpoints. Maybe Ctrl+Drag of a point could "extrude" a new point out of it (if it's an end-point)?

Please tell me what you think?

der-On avatar Apr 29 '14 09:04 der-On

You can programatically ensure that there is only one feature (layer) available in the edit layer group, and then invoke the edit functionality. This ensures that there is no confusion about what is being edited... I don't know whether a ctrl+drag operation would interfere with anything else, but certainly the idea of holding an endpoint fixed whilst extending the line onwards (or in another direction) has its merits. I'd +1 on that as an enhancement (probably endpoints only else if it were possible on other nodes, it would become a multiLinestring). Identifying and editing individual features is not an issue though....

Before: image

Edit 1: image

Edit 2: image

peterb-2795 avatar Apr 29 '14 10:04 peterb-2795

While drawing some tourist routes in the Mapbox editor for my friends, just discovered that I'd love to see this too. :) E.g. someone draws a route, then accidentally triggers draw end — how would he go back to drawing the line? I'd expect maybe enabling the draw mode again if you click on the last point, or at least have it as an option. @jacobtoye thoughts?

mourner avatar May 02 '14 20:05 mourner

This is something I really need in a collaborative mapping tool I'm creating. The only way I can see to get the functionality I want is to have the users create a start and end point and then drag out the nodes in between. That really isn't very intuitive and users would expect to be able to continue drawing at the end of the path.

adrianritchie avatar Feb 03 '15 12:02 adrianritchie

+1

In fact, I think it's too easy to delete a node by just clicking on it. Maybe a Ctrl+Click or so would be more intuitive?

plepe avatar Sep 15 '15 01:09 plepe

What about using a keyboard shortcut "e" to extrude the currently selected point (would only work for start and end points)

der-On avatar Sep 15 '15 07:09 der-On

Has this been implemented by chance? Or did anyone manage to find a simple solution to simulate this?

I really need this feature and the only thing I could think of to achieve it was something complicated like:

  • get into edit mode with the polyline
  • find a way to trigger continuing line (like a keypress or a right click on the last marker, quite complicated as the handlers are not initialised when the EDITSTART event is called and I have no way to know when the handlers finished initialisation)
  • get back to drawing mode and programatically add all points from your existing layer (polyline)
  • delete existing layer and let the user continue line from the last point

The OpenStreetMap ID editor (for example) has a very nice feature to append points to existing line, click a "PLUS" button there and continue the line. I would like some functionality similar to that.

mdomnita avatar Apr 12 '17 10:04 mdomnita

You can use the addLatLng() method -- http://leafletjs.com/reference-1.0.3.html#polyline

sumitkamath avatar Apr 17 '17 21:04 sumitkamath

mdomnita - if #651 was merged in, you could just capture map.on(L.Draw.Event.EDITHOOK to get the editHandler. Unfortunately, it looks like the maintainers of L.Draw have lost interest in this project. However, feel free to merge it for yourself.

(note: if you're interested, please let me know because there's a few small bugfixes for that code that I've developed in the last 5 months that I've never pushed in)

germanjoey avatar Apr 18 '17 02:04 germanjoey

I've posted a spinoff feature request at iD editor repo related to this: https://github.com/openstreetmap/iD/issues/5426

answerquest avatar Oct 24 '18 04:10 answerquest

@mdomnita man, you should really work on your github formatting skills.

Candyffm avatar Jul 10 '20 07:07 Candyffm

@mdomnita man, you should really work on your github formatting skills.

I'm sorry that my comment from 2017 bothered you two years after anyone touched this project. I hoped that my hack might help someone get this issue solved and did not have time for a PR then. Apparently, it didn't... so I deleted it now and it will not bother anyone in the future.

Thanks.

mdomnita avatar Jul 12 '20 12:07 mdomnita