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

React Example #32

Closed
kaditya97 opened this issue Jun 15, 2022 · 7 comments
Closed

React Example #32

kaditya97 opened this issue Jun 15, 2022 · 7 comments

Comments

@kaditya97
Copy link

I am trying to use it with react but get plenty of errors. Can someone help me with an example of it or guide me on how to set it properly.

@pavan2108
Copy link

Can you describe your issue so if I can help you out I will get in to the project

@kaditya97
Copy link
Author

In which file we are supposed to put this code?

plugins: [
new CopyWebpackPlugin({
patterns: [
{ from: '../node_modules/gdal3.js/dist/package/gdal3WebAssembly.wasm', to: 'static' },
{ from: '../node_modules/gdal3.js/dist/package/gdal3WebAssembly.data', to: 'static' }
]
})
]

@kaditya97
Copy link
Author

Here is the error that occurs when I run the project
image

@bugra9
Copy link
Owner

bugra9 commented Jul 17, 2022

Hi @kaditya97, sorry for replying so late.

I used single file for node and browser so this issue occurred. In a few days I will separate them and release the new version. I will also add a use case for react.

@kaditya97
Copy link
Author

@bugra9 thank you for addressing the issue, will be waiting for the release.

@bugra9
Copy link
Owner

bugra9 commented Jul 24, 2022

@kaditya97, I have released a new version (v2.2.0). Can you try this version?

Example Usage:

import initGdalJs from 'gdal3.js';

import dataUrl from 'gdal3.js/dist/package/gdal3WebAssembly.data'
import wasmUrl from 'gdal3.js/dist/package/gdal3WebAssembly.wasm'

const paths = {
  wasm: wasmUrl,
  data: dataUrl,
};

initGdalJs({paths, useWorker: false}).then(Gdal => console.log(Object.keys(Gdal.drivers.raster).length + Object.keys(Gdal.drivers.vector).length));

@kaditya97
Copy link
Author

@bugra9 Thank you, it is working now.

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