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

L.Draw.Feature.addInitHook(...) stopped working in 0.4.13 #857

Open
6 tasks done
richardhinkamp opened this issue Apr 24, 2018 · 3 comments
Open
6 tasks done

L.Draw.Feature.addInitHook(...) stopped working in 0.4.13 #857

richardhinkamp opened this issue Apr 24, 2018 · 3 comments

Comments

@richardhinkamp
Copy link

  • I'm reporting a bug, not asking for help
  • I've looked at the documentation to make sure the behaviour is documented and expected
  • I'm sure this is a Leaflet Draw code issue, not an issue with my own code nor with the framework I'm using (Cordova, Ionic, Angular, React…)
  • I've searched through the issues to make sure it's not yet reported

How to reproduce

  • Leaflet version I'm using: 1.0.2 or 1.3.1, not relevant
  • Leaflet Draw version I'm using: 1.0.2
  • Browser (with version) I'm using: any
  • OS/Platform (with version) I'm using: any

Found out about this because I'm using leaflet-snap which add an initHook here: https://github.com/makinacorpus/Leaflet.Snap/blob/5597677fe16744219c480afe7c7e7fce78cc71fd/leaflet.snap.js#L659

In #772 the events mixin was changed for leaflet 1.2+ to use L.Evented.prototype instead of L.Mixin.Events. But it was also moved from the prototype declaration to the init function. So an added init hook (L.Draw.Feature.addInitHook(function() {});) is done before the initialize function and added to the _initHooks props. In the initialize function it includes the L.Evented.prototype or L.Mixin.Events mixin which includes a property _initHooks (empty array) and so override the current added init hooks.

What behaviour I'm expecting and which behaviour I'm seeing

The init hook should be called, but isn't.

Minimal example reproducing the issue

  • this example is as simple as possible
  • this example does not rely on any third party code

With leaflet-draw 0.4.12 the init hook is called:
https://jsfiddle.net/mvp7hgou/44/
With leaflet-draw 0.4.13 the init hook is not called:
https://jsfiddle.net/mvp7hgou/45/

I guess L.Toolbar has the same problem.

@rodriguesrl
Copy link

Any update on this? I really need to use the snap plugin with leaflet draw.

@diamondskrt
Copy link

Any update on this? I really need to use the pin plugin with leaflet draw.

@MiirzaBaig
Copy link

Has it been resolved or yet to be resolved?

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

4 participants