umap-project / umap

uMap lets you create maps with OpenStreetMap layers in a minute and embed them in your site.
https://umap-project.org
Other
1.17k stars 224 forks source link

Snap Interaction #2159

Open DiffPetrovich opened 3 weeks ago

DiffPetrovich commented 3 weeks ago

Is your feature request related to a problem? Please describe. Please make snapping/sticking feature, e.g. when we draw new line/point, it can be attached exactly to an existing one, just like in any CAD system or OSM data editor. Umap very lacks this.

Describe the solution you'd like One of these: 1) While drawing a line/point, when the mouse is near an existing one, the latter is highlighted. When we click during this highlight, the new point is creating at the nearest position from the mouse exactly on top of the highlighted one (CADs usually use this approach). 2) While drawing a line/point, when the mouse is near an existing one, the point instantly sticks to it and we can adjust the position and click the mouse to create (see example below).

Also the snapping should be when a line ends on itself.

Describe alternatives you've considered None. I import some OSM data and want to draw manually on top of that, connecting points/lines, but the precise mapping with this soft is impossible since new geometry's points are created at some distance from the existing vector's axis/center and this distors the final map.

Additional context You can see the example here: https://openlayers.org/en/latest/examples/snap.html (I understand, that you use Leaflet and this may be its problem, but decided to put the issue here, the final product, for more people to know about it).

yohanboniface commented 1 week ago

https://github.com/makinacorpus/Leaflet.Snap may help, but seems to only work with Leaflet.Draw, so it may require a bit of work to make it compliant with Leaflet.Editable