wgnhs / lslc-web-app

Web Application for the viewing the WGNHS Lake Superior Legacy Collection
https://wgnhs.github.io/lslc-web-app/
1 stars 0 forks source link

Leaflet Draw error (el.parentNode is null) #79

Open cmrRose opened 7 years ago

cmrRose commented 7 years ago

I sometimes end up triggering this error when using the Draw capability: el.parentNode is null

image

I haven't figured out how to cause it exactly. It seems to disrupt the draw-end event somehow. Once this occurs, any attempt to draw a polygon produces the same error.

cmrRose commented 7 years ago

When this error happens, the L.Draw.Event.CREATED event does happen, but the L.Draw.Event.DRAWSTOP does not happen. If I can eventually get DRAWSTOP to happen, this seems to end the errors. No longer seems to be the case. I can get DRAWSTOP to occur, yet still get this error.

cmrRose commented 7 years ago

May be related to the .bringToFront(); method?

cmrRose commented 7 years ago

I have now added a function disableLeafletDraw() that is called on both L.Draw.Event.DRAWSTOP and on L.Draw.Event.CREATED. This eliminates the problem of leaflet trying to continue drawing a second shape. It still, however, produces the same error (el.parentNode is null) on occasion, and I can't figure out what causes it.

Although the new Leaflet Draw shape appears to be complete, somehow this error prevents my code from continuing to query using the geometry of the new shape.

cmrRose commented 7 years ago

image

cmrRose commented 7 years ago

It seems that leafletFeatureLayer.bringToFront(); was throwing the error and causing the code to stop before calling the function to query for geometry.

I moved 'bringToFront' after the query function call. I continue to get the same error, but at least it doesn't stop the query from happening. The only problem it causes now is that the draw polygon remains on top of some (not all) of the sections, blocking the user from clicking on a section to see a popup.

cmrRose commented 6 years ago

Here is a work-around: https://gis.stackexchange.com/questions/238166/allow-popups-to-show-through-another-layer