Closed immanewel closed 9 months ago
I am getting the above error when trying to read an uploaded shapefile in an angular project,
onFileSelected(event: Event) { const inputElement = event.target as HTMLInputElement; const file = inputElement?.files?.[0];
const fileReaderJson: FileReader = new FileReader(); if (!file) return; fileReaderJson.onloadend = (x) => { parseZip(x?.target?.result as ArrayBuffer) .then((geojson) => { alert(geojson); }) .catch((err) => alert(err)); }; fileReaderJson.readAsArrayBuffer(file);
}
the complete source code at the codesandbox url
https://codesandbox.io/p/sandbox/angular-shapefile-reading-s8d4qh?file=%2Fsrc%2Fapp%2Fapp.component.ts%3A11%2C11-11%2C15
Adding to polyfills.ts solved the issue:
global.Buffer = global.Buffer || require('buffer').Buffer;
Thanks, I had to use combine, parseDbf, parseShp to achieve this.
I am getting the above error when trying to read an uploaded shapefile in an angular project,
onFileSelected(event: Event) { const inputElement = event.target as HTMLInputElement; const file = inputElement?.files?.[0];
}
the complete source code at the codesandbox url
https://codesandbox.io/p/sandbox/angular-shapefile-reading-s8d4qh?file=%2Fsrc%2Fapp%2Fapp.component.ts%3A11%2C11-11%2C15