Leaflet.draw icon indicating copy to clipboard operation
Leaflet.draw copied to clipboard

polygon.editing.enable() error

Open wmaiouiru opened this issue 6 years ago • 11 comments

  • [x] I'm reporting a bug, not asking for help
  • [x] I've looked at the documentation to make sure the behavior 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.3
  • Leaflet Draw version 0.4.13 [0.4.12 works].
  • Browser (with version) I'm using: Chrome 62.0.3202.94
  • OS/Platform (with version) I'm using: macOS Sierra Version 10.12.4
  • step 1 The following example code is broken. http://leaflet.github.io/Leaflet.draw/docs/examples/edithandlers.html
  • step 2

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

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

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

wmaiouiru avatar Nov 14 '17 21:11 wmaiouiru

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.

CmdSec avatar Nov 15 '17 12:11 CmdSec

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)

pilarArr avatar Nov 15 '17 16:11 pilarArr

I solved it for now with this: polygon.options.editing || (polygon.options.editing = {}); polygon.editing.enable();

from #364

xinaris avatar Nov 18 '17 04:11 xinaris

Pls fix it in libary

TravnikovDev avatar Feb 15 '18 16:02 TravnikovDev

I had the same issue, but with @NovinNovin code changes the issue is fixed. Please fix it the lib.

errazkisibawaih avatar Feb 21 '18 17:02 errazkisibawaih

This error is happening with version leaflet-draw v1.0.2 , is there an open branch for a fix ?

cecilepolestarglobal avatar Mar 15 '18 12:03 cecilepolestarglobal

I think #838 closes this issue?

knownasilya avatar May 08 '18 13:05 knownasilya

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

Chris1234567899 avatar May 17 '18 14:05 Chris1234567899

Workaround:

You can put placeholder editing property in shapeOptions:

new L.Control.Draw(
  {draw: {
    polygon: {
      shapeOptions: {
        editing: {
          className: ""}}}}}})

akaivola avatar Jun 04 '18 12:06 akaivola

The leaflet draw examples for v1+ actually use v0.4.2

pilarArr avatar Jun 28 '18 11:06 pilarArr

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:

alexandervlpl avatar Mar 01 '23 11:03 alexandervlpl