Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

geobuf.decode error #129

Open
tangzijun opened this issue Jul 30, 2023 · 2 comments
Open

geobuf.decode error #129

tangzijun opened this issue Jul 30, 2023 · 2 comments

Comments

@tangzijun
Copy link

When I execute geobuf.decode, an error is reported:

image

image

@rmcf
Copy link

rmcf commented Dec 15, 2023

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
Copy link

NathanPB commented Jan 4, 2024

I am facing the same issue when the code is minified with webpack. I suppose that this is the reason:

image

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/ })
      ],
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants