Closed lautarodapin-magoya closed 10 months ago
I change the code because ii read the the input filies must be a arraybuffer to but i get the same error
const files = [...e.target.files];
const buffers = await Promise.all(files.map((file) => fileRead(file)));
const input = files.reduce((acc, curr, i) => {
acc[curr.name] = buffers[i];
return acc;
}, {});
const names = files.map((file) => file.name).join(' -i ');
const cmd = `${files.map((file) => `-i ${file.name}`).join(' ')} -o format=geojson`;
console.log({cmd, input});
// mapshaper.runCommands(`${files.map((file) => `-i ${file.name}`).join(' ')} -o geojson.json format=geojson`);
mapshaper.applyCommands(cmd, input, (err, output) => {
console.log(err);
console.log(output);
});
I see... you want to use the JS api in a web browser. The -i
command doesn't work in the console of the mapshaper web UI, which is why I added the error message that you're seeing. I'll try to get this fixed for you in the next release. Thanks for filing this issue :)
thanks for the fast response! @mbloch how the https://mapshaper.org/ works? i try to search in the source code how it does it, but i couldn't solve it
Hi, I think that I fixed the problem that you were having using applyCommands
in the browser. You can try v0.6.51, which I just published.
https://mapshaper.org just serves a static web page, it's the same page as index.html
in the www/
folder of the github repo. Mapshaper will mostly work if you open the index.html
file in a web browser.
I'm getting this error
UserError: [i] The -i command cannot be run in the browser
when trying to use mapshaper in the browserI have the scriipts
modules.js
andmapshaper.js
present, the an input to read the shapefile, then i call the following code601 #407 i checked this two issues but i couldnt solve it