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

Vue3, Leaflet, and Plugin cause multiple instances of leaflet #5

Open
GalenReich opened this issue Aug 2, 2024 · 0 comments · May be fixed by #8
Open

Vue3, Leaflet, and Plugin cause multiple instances of leaflet #5

GalenReich opened this issue Aug 2, 2024 · 0 comments · May be fixed by #8
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@GalenReich
Copy link
Contributor

At the moment, the project uses Vue3 and a beta version of Vue-Leaflet that supports Vue3 (the stable version only supports Vue2).

There is an issue, documented here: vue-leaflet/vue-leaflet#48 (comment) which results in two instances of leaflet being imported.

The recommended solution is to import * as L from 'leaflet/dist/leaflet-src.esm'; which works, but causes issues with using the Leaflet-AreaSelect plugin which requires L to be available.

Though L is available when import * as L from 'leaflet/dist/leaflet-src.esm'; is used, the plugin fails either with an:

Uncaught ReferenceError: L is not defined (when importing the plugin immediately after leaflet)
or
L.AreaSelect is read-only (if leaflet is imported in main.js) - this references the first line of the plugin

This may be related to ES6 imports: Leaflet/Leaflet.markercluster#874

@GalenReich GalenReich added bug Something isn't working help wanted Extra attention is needed labels Aug 2, 2024
@GalenReich GalenReich linked a pull request Aug 7, 2024 that will close this issue
@GalenReich GalenReich linked a pull request Aug 7, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant