2

I'm trying to use Shpjs package for import Shape file on leaflet map based on the shpjs doc : shpjs

Here is my code :

      const [geoData, setGeoData] = useState(null); //state
      //onChange function
      const onChangeFile = ({ target }) => {
      var reader = new FileReader();
      var file = target.files[0];
      reader.readAsArrayBuffer(file);
      reader.onload = function (buffer) {
        setGeoData(buffer.target.result);
      };
    };

and after that i use shpjs package like this :

 const geoJson =  await shp(geoData)

after import shp.zip i get this error : Error

How can I fix this?

  • You should put the error as text for better reference. A minimal reproducible example is also preferable – Kins Jan 16 '23 at 12:28

1 Answers1

0

you can use npm package const NodePolyfillPlugin = require('node-polyfill-webpack-plugin'); and in react node modules config file and in webpackconfig add the package above refer this link jay patel author