Commit 8433a898 authored by Juan gomez's avatar Juan gomez
Browse files

feat: Add useGlobalLeaflet option prop

The useGlobalLeaflet option prop allows the user to mount the Lmap component by using the globally available leaflet instance instead of the one imported from the ESM file. This allows some plugins that require to have a global leaflet to be present to work with this component. By default the option is set to false.
parent e12db20d
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -219,7 +219,6 @@ export default {
    };

    onMounted(async () => {
      WINDOW_OR_GLOBAL.L = WINDOW_OR_GLOBAL.L || (await import("leaflet"));
      const {
        map,
        CRS,
@@ -227,7 +226,9 @@ export default {
        latLngBounds,
        latLng,
        DomEvent,
      } = WINDOW_OR_GLOBAL.L;
      } = options.useGlobalLeaflet
        ? (WINDOW_OR_GLOBAL.L = WINDOW_OR_GLOBAL.L || (await import("leaflet")))
        : await import("leaflet/dist/leaflet-src.esm");

      try {
        options.beforeMapMount && (await options.beforeMapMount());
+1 −1
Original line number Diff line number Diff line
export const props = {
  options: {
    type: Object,
    default: () => ({}),
    default: () => ({ useGlobalLeaflet: false }),
  },
};