Leaflet.CanvasLayer.Field icon indicating copy to clipboard operation
Leaflet.CanvasLayer.Field copied to clipboard

`TypeError` upon removing `VectorField` layer from map using layer control

Open zacharyburnett opened this issue 7 years ago • 2 comments

When unchecking a VectorFieldAnim layer from a layer control, the console shows the following error several hundred times:

Uncaught TypeError: Cannot read property 'latLngToContainerPoint' of null
    at e._drawParticle (L.CanvasLayer.VectorFieldAnim.js:122)
    at L.CanvasLayer.VectorFieldAnim.js:109
    at Array.forEach (<anonymous>)
    at n (L.CanvasLayer.VectorFieldAnim.js:108)
    at L.CanvasLayer.VectorFieldAnim.js:52
    at Mn (d3.v4.min.js:2)
    at Tn (d3.v4.min.js:2)

Is some asynchronous particle calculation not stopping after removing the map?

zacharyburnett avatar Aug 17 '18 16:08 zacharyburnett

I can reproduce this behavior with the following steps using a layer control:

  1. Add the VectorFieldAnim layer

  2. Add a ScalarField layer, in this case from an ASCII grid file

  3. Remove the VectorFieldAnim layer

The errors stop when the VectorFieldAnim layer is put back into the map

zacharyburnett avatar Aug 17 '18 17:08 zacharyburnett

Perhaps related https://github.com/IHCantabria/Leaflet.CanvasLayer.Field/issues/41 (I have the same behaviour)

rmarzocchi84 avatar Nov 04 '20 14:11 rmarzocchi84