Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leaflet draw not snap features with latest release #52

Open
ToDentru opened this issue Jan 12, 2019 · 5 comments
Open

Leaflet draw not snap features with latest release #52

ToDentru opened this issue Jan 12, 2019 · 5 comments

Comments

@ToDentru
Copy link

Hi guys, i need use the plugin with Leaflet v1.4.0 and Leaflet.Draw v1.0.4, but when add new feature from draw toolbar...the snap function don't activate from existent features. I try use your test page...updating only Leaflet and Leaflet.Draw...but no success. No console errors or warnings...absolutely silence mode. Exists the possibility of the new build with compatibility? When?

@madinaxd
Copy link

madinaxd commented May 15, 2019

I added these three lines of code and everything works now
L.Draw.Feature.include(L.Evented.prototype); L.Draw.Feature.include(L.Draw.Feature.SnapMixin); L.Draw.Feature.addInitHook(L.Draw.Feature.SnapMixin._snap_initialize);

@SergeBouchut
Copy link

Same for me with:

  • leaflet 1.5.1
  • leaflet-draw 1.0.4
  • leaflet-geometryutil 0.9.1
  • leaflet-snap 0.0.4

Adding @madinaxd three lines of code works to activate snap but the click remains allowed outside the snap target so the lines are disjoint.

@andrewpeters9
Copy link

Did you guys find a fix for this? @SergeBouchut @madinaxd @ToDentru

@daz
Copy link

daz commented Jan 20, 2020

Same for me:

leaflet-draw 1.0.4
leaflet-geometryutil 0.9.1
leaflet-snap 0.0.4
leaflet 1.6.0

The Leaflet.Draw snapping demo doesn't seem to work either

@andrewpeters9
Copy link

@daz I managed to get it working, but it's not pretty.

I forked both leaflet draw and leaflet snap.

I then found this L.Draw.Feature.SnapMixin = { part of the leaflet snap library and moved all the methods of it into L.Draw.Feature.

I then removed the hooks the leaflet snap creates, and I replaced then with internal method calls. E.g. in the enable method of L.Draw.Feature in leaflet.draw, I added this: this._snap_on_enabled.call(this);

I did the same with the disabled methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants