Leaflet.draw
Leaflet.draw copied to clipboard
L.Draw.Feature.addInitHook(...) stopped working in 0.4.13
- [x] I'm reporting a bug, not asking for help
- [x] I've looked at the documentation to make sure the behaviour is documented and expected
- [x] 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…)
- [x] 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
- [x] this example is as simple as possible
- [x] 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.
Any update on this? I really need to use the snap plugin with leaflet draw.
Any update on this? I really need to use the pin plugin with leaflet draw.
Has it been resolved or yet to be resolved?