Open wmaiouiru opened 6 years ago
In my case it's the same problem but even sometimes for all shapes i want to edit like lines, circle etc. in Chrome:
Uncaught TypeError: Cannot read property 'className' of undefined at e.addHooks (leaflet.draw.js:8) at leaflet.draw.js:8 at e._eachVertexHandler (leaflet.draw.js:8) at e.addHooks (leaflet.draw.js:8) at enable (leaflet.js:5) at e._enableLayerEdit (leaflet.draw.js:9) at eachLayer (leaflet.js:5) at e.addHooks (leaflet.draw.js:9) at enable (leaflet.js:5) at enable (leaflet.draw.js:9)
I'm using Leaflet 1.2.0 and Leaflet.draw 0.4.13. This version have less "Deprecated include of L.Mixin.Events:" errors by the way. So i also need to fall back to version 0.4.12 at the moment.
Error occurs on Chrome 62.0.3202.94 (64-Bit) and Opera 49.0.2725.34 (PGO). Firefox Quantum 57.0 (64-Bit) can handle 0.4.13 just noticed.
I have this issue too, also worked in 0.4.12.
I get this error when I activate editing on a GeoJSON layer with a LineString, which I guess would translate to a polyline
modules.js?hash=5e19341881f7c142cc52aeeeb90f6be7e92646ca:17209
Uncaught TypeError: Cannot read property 'className' of undefined
at NewClass.addHooks (modules.js?hash=5e19341881f7c142cc52aeeeb90f6be7e92646ca:17209)
at modules.js?hash=5e19341881f7c142cc52aeeeb90f6be7e92646ca:17209
at NewClass._eachVertexHandler (modules.js?hash=5e19341881f7c142cc52aeeeb90f6be7e92646ca:17209)
at NewClass.addHooks (modules.js?hash=5e19341881f7c142cc52aeeeb90f6be7e92646ca:17209)
at NewClass.enable (modules.js?hash=5e19341881f7c142cc52aeeeb90f6be7e92646ca:9114)
at MissionMap.componentDidUpdate (MissionMap.js:245)
at commitLifeCycles (modules.js?hash=5e19341881f7c142cc52aeeeb90f6be7e92646ca:29403)
at commitAllLifeCycles (modules.js?hash=5e19341881f7c142cc52aeeeb90f6be7e92646ca:30564)
at HTMLUnknownElement.callCallback (modules.js?hash=5e19341881f7c142cc52aeeeb90f6be7e92646ca:21137)
at Object.invokeGuardedCallbackDev (modules.js?hash=5e19341881f7c142cc52aeeeb90f6be7e92646ca:21176)
I solved it for now with this: polygon.options.editing || (polygon.options.editing = {}); polygon.editing.enable();
from
Pls fix it in libary
I had the same issue, but with @NovinNovin code changes the issue is fixed. Please fix it the lib.
This error is happening with version leaflet-draw v1.0.2
, is there an open branch for a fix ?
I think #838 closes this issue?
The same thing seems to happen to other geometry types as it seems:
marker -> different error (Cannot read property 'enable' of undefined) circle -> works linestring -> same error rectangle -> works polygon -> same error
Workaround:
You can put placeholder editing
property in shapeOptions:
new L.Control.Draw(
{draw: {
polygon: {
shapeOptions: {
editing: {
className: ""}}}}}})
The leaflet draw examples for v1+ actually use v0.4.2
Sadly this library seems to be abandoned now. I ran into this and similar issues while upgrading Leaflet and Draw, now considering migrating to Geoman instead. :cry:
How to reproduce
What behaviour I'm expecting and which behaviour I'm seeing
The problem seems to be at: polygon.editing.enable() In L.Edit.PolyVerticesEdit, editing in poly.options.editing.className is not defined. The options in polygon editing is an empty object.
Minimal example reproducing the issue
Using jsfiddle or another example site. http://leaflet.github.io/Leaflet.draw/docs/examples/edithandlers.html Check the console output.
The problem might be this commit: https://github.com/Leaflet/Leaflet.draw/commit/35c6b5736d298c206594e08db0117702a791446a