calvinmetcalf / shapefile-js

Convert a Shapefile to GeoJSON. Not many caveats.
http://calvinmetcalf.github.io/shapefile-js/
715 stars 228 forks source link

Read shapefile with React #130

Closed annfr542 closed 3 years ago

annfr542 commented 3 years ago

Hi, I'm quite new to React and trying to read a shapefile. I'm using this code:

shp("../data/shapefiles/shapefile.zip").then(function (geojson) { //do something with your geojson console.log(geojson); });

And I get the following error

Uncaught (in promise) Error: Can't find end of central directory : is this a zip file ? If it is, see http://stuk.github.io/jszip/documentation/howto/read_zip.html at ZipEntries.readEndOfCentral (zipEntries.js:173) at ZipEntries.load (zipEntries.js:274) at new ZipEntries (zipEntries.js:22) at JSZip.push../node_modules/jszip/lib/load.js.module.exports [as load] (load.js:19) at new JSZip (index.js:39) at push../node_modules/shpjs/lib/unzip.js.module.exports (unzip.js:5) at Function.push../node_modules/shpjs/lib/index.js.shp.parseZip (index.js:65) at index.js:113

Do you have any idea on how I can fix it?