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

Map widget : use dynamic import for leaflet to avoid overriding the leaftlet from sparnatural-yasgui-plugin if it is imported first #584

Open
tfrancart opened this issue Apr 24, 2024 · 0 comments
Assignees
Labels
kind: Enhancement 📈 New feature or request

Comments

@tfrancart
Copy link
Contributor

This kind of thing:

// /!\ black magic warning : dynamic leaflet import
// to avoid importing it twice in the page
var L:typeof import("leaflet/index");
var markerIcon;
if(window.L == undefined) {
    import("leaflet").then((theLeaflet) => {
        L = theLeaflet;
        window.L = L;
        import('leaflet.markercluster');
        markerIcon = L.icon( {
            iconUrl:require("leaflet/dist/images/marker-icon.png"),
            shadowUrl: require("leaflet/dist/images/marker-shadow.png")
        } );
    });
} else {
    L = window.L;
    import('leaflet.markercluster');
    markerIcon = L.icon( {
        iconUrl:require("leaflet/dist/images/marker-icon.png"),
        shadowUrl: require("leaflet/dist/images/marker-shadow.png")
    } );
}
// /!\ end blackmagic
@tfrancart tfrancart added the kind: Enhancement 📈 New feature or request label Apr 24, 2024
@tfrancart tfrancart self-assigned this Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: Enhancement 📈 New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant