mapbox / shp-write

create and write to shapefiles in pure javascript
BSD 3-Clause "New" or "Revised" License
290 stars 186 forks source link

Error: This method has been removed in JSZip 3.0, please check the upgrade guide. #48

Closed ghost closed 10 months ago

ghost commented 7 years ago

Hi, I'm using the latest version 0.3.2 and when executing shpwrite.download() I get following Error:

Error: This method has been removed in JSZip 3.0, please check the upgrade guide.

Do I do something wrong or is it a bug? Is there a work-around?

Here is my code;:

var shp_options = { folder: 'shapefiles', types: { point: 'points', polygon: 'polygons', polyline: 'polyline' }}; var geojson_format = new OpenLayers.Format.GeoJSON(); var features_geojson = JSON.parse(geojson_format.write(drawLayer.features,false));
shpwrite.download(features_geojson,shp_options);

Cheers, Steffen

malvandi commented 7 years ago

Do you have solved it? I have the same problem.

ghost commented 7 years ago

no, unfortunately not. I still don't have the shape write implement. Until now I can live with geojson...

simtrax commented 7 years ago

I have this issue as well.

ximex commented 7 years ago

I fixed it by hand. Replace this:

// ##### replace this:
var generateOptions = { compression:'STORE' };

if (!process.browser) {
  generateOptions.type = 'nodebuffer';
}

return zip.generate(generateOptions);

// ##### with this:
var generateOptions = { compression:'STORE', type:'base64' };

if (!process.browser) {
  generateOptions.type = 'nodebuffer';
}

return zip.generateAsync(generateOptions);

// ##### and this:
module.exports = function(gj, options) {
  var content = zip(gj, options);
  location.href = 'data:application/zip;base64,' + content;
};

// ##### with this:
module.exports = function(gj, options) {
  zip(gj, options).then(function(content) {
    location.href = 'data:application/zip;base64,' + content;
  });
};

Look at: https://stuk.github.io/jszip/documentation/upgrade_guide.html

Edit: I use FileSaver.js (https://github.com/eligrey/FileSaver.js) and have to change type:'base64' to type:'blob' So:

shpwrite.zip(data, options).then(function(content) {
  saveAs(content, 'export.zip');
});
kmanzana commented 4 years ago

Does it make sense to introduce this change via a PR?

sheindel commented 10 months ago

JSZip ahs been upgraded in the latest tagged version (v0.4.0). Will be released on npm soon.