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

Please update for WebApps (eg. react-leaflet) #60

Open
oehm-smith opened this issue May 1, 2024 · 0 comments
Open

Please update for WebApps (eg. react-leaflet) #60

oehm-smith opened this issue May 1, 2024 · 0 comments

Comments

@oehm-smith
Copy link

I could not find any information on how to get this plugin working in a https://www.npmjs.com/package/react-leaflet (ie. React or any WebApp) project. I had to perform the following - oh, its a Typescript project also but after playing around with this problem it seems that I don't need to modify the tsConfig.ts, although theoretically the below change will help in the IDE. However despite specifying a directory I could not see a types directory being made nor .d.ts files being generated (such dirs and files already existed before this change). Maybe that is only for local .js files and not ones in node_modules:

// tsConfig.ts
  "compilerOptions": {
    ...
    "emitDeclarationOnly": true,
    "declarationDir": "./types",
}
// App.tsx
import "./init";       // necessary to have a definition for global
import "leaflet-ajax"; 
import L, {
    ...
} from "leaflet";
import {
  MapContainer,
  ...
} from "react-leaflet";
//init.js
window.global ||= window;

I'm not sure if there is a better way to achieve this, although for one thing it would be helpful to have a .d.ts file (eg @types/leaflet-ajax) for when using this with Typescript.

If there is a better way please let us know. If not could you add this information to the readme?

Or perhaps I should be posting this issue to the https://github.com/Leaflet/Leaflet project as a general issue with plugins. Thoughts?

@oehm-smith oehm-smith changed the title Please update for WebApps Please update for WebApps (eg. react-leaflet) May 1, 2024
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

1 participant