onaci / leaflet-velocity

Visualise velocity data on a leaflet layer

Home Page:https://onaci.github.io/leaflet-velocity/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot read properties of null (reading 'containerPointToLayerPoint')

abhishek73magar opened this issue · comments

my code:


  useEffect(() => {
    if (map) {
      // const url = `https://onaci.github.io/leaflet-velocity/wind-global.json`;
      const url = 'http://localhost:3000/wind.json'
      axios
        .get(url, { withCredentials: false })
        .then((res) => {
          console.log(res);
          console.count('run:')
          if(windRef.current) {
            map.removeLayer(windRef.current)
          }
          windRef.current = new L.velocityLayer({
            displayValues: true,
            displayOptions: {
              velocityType: "Wind",
              position: "bottomleft",
              emptyString: "No Wind data",
              showCardinal: true,
              speedUnit: "ms",
            },
            data: res.data,
            maxVelocity: 25,
            velocityScale: 0.01, // arbitrary default 0.005

            // colorScale: ["red", "blue"],
            paneName: "Wind Overlay Pane",
          })
          map.addLayer(windRef.current)
          console.log('--------done--------')
        })
        .catch((err) => console.error(err));
    }
  }, [map]);

  return null;
};

while removeing layer from map got error

Cannot read properties of null (reading 'containerPointToLayerPoint')
TypeError: Cannot read properties of null (reading 'containerPointToLayerPoint')
    at NewClass._onLayerDidMove (http://localhost:3000/static/js/vendors-node_modules_leaflet-velocity_dist_leaflet-velocity_js-node_modules_react-leaflet_lib-c3c173.chunk.js:53:29)
    at http://localhost:3000/static/js/vendors-node_modules_leaflet-velocity_dist_leaflet-velocity_js-node_modules_react-leaflet_lib-c3c173.chunk.js:86:12

is any once encounter such error if yes please help me