mapbox / shp-write

create and write to shapefiles in pure javascript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

sjohn-atenekom opened this issue · comments

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

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

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

I have this issue as well.

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');
});

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

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