vue-leaflet/Vue2Leaflet

L object imported and undefined

KrzysztofT opened this issue · 1 comments

L object undefined (but accessible from window object)

Live Demo

https://codesandbox.io/s/great-pare-6ev13?file=/App.vue

Steps to Reproduce

As provided in the example from the LIcon.vue file, import L:

import { L } from "leaflet";

And try to access it:

console.log(L)

Expected Results

The L object is defined and in the scope. It should be returned to the console.

Actual Results

The L is undefined. On the other hand, console.log(window.L) works.

I see that similar issues have been brought up in the past and all the answers suggest that the L object used to just work so something must have changed since then. Using window.L is a quick solution but I wouldn't like to use it as it seems a bit hacky.

Browsers Affected

  • Chrome
  • Firefox
  • Edge
  • Safari 9
  • Safari 8
  • IE 11

Versions

  • Leaflet: v1.7.1
  • Vue: v2.6.11
  • Vue2Leaflet: v2.5.2
mikeu commented

Hi @KrzysztofT , thanks for this issue, though this library is not actually affiliated with Leaflet, and we have no control here over their code. As far as I know, they simply don't export anything named L, so it can't be imported. You can import their whole library as L though (i.e. import L from "leaflet";) instead if you want access to it: https://codesandbox.io/s/amazing-cray-jyce5