geobuf.decode error
Opened this issue · 2 comments
tangzijun commented
rmcf commented
To decode geobuf with a "manual" fetch I use this:
import geobuf from "geobuf";
import Pbf from "pbf";
function getCompressedData(geobufFileUrl) {
fetch(geobufFileUrl)
.then((response) => response.arrayBuffer())
.then((buffer) => {
const geoJsonData = geobuf.decode(new Pbf(buffer));
createMap(geoJsonData);
});
}
NathanPB commented
I am facing the same issue when the code is minified with webpack. I suppose that this is the reason:
Workaround:
My workaround at the moment is to use the Terser webpack plugin to ignore geobuf when minifying the code:
npm i -D terser-webpack-plugin
// webpack.config.js
module.exports = {
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({ exclude: /node_modules\/geobuf/ })
],
}
}