Esri / esri-leaflet-vector

Display ArcGIS Online vector basemaps w/ Esri Leaflet
Apache License 2.0
56 stars 57 forks source link

Error when using esri-leaflet-vector-debug build #171

Closed gavinr closed 1 year ago

gavinr commented 1 year ago

Describe the bug

When developing locally, we have the pattern of including maplibre-gl and esri-leaflet-vector-debug.js as separate script tags. This works fine:

https://github.com/Esri/esri-leaflet-vector/blob/291e1add45b3cc2869d32b3dd13634c3f60ee51b/examples/quickstart-dev.html#L16-L20

But when trying to use the same pattern with the CDN build (https://unpkg.com/esri-leaflet-vector@3.1.5/dist/esri-leaflet-vector-debug.js), I get an error (see reproduction case below).

Reproduction

Load https://jsbin.com/lidiviqowo/edit?html,output

Logs

MapBoxGLLayer.js:143:

Uncaught TypeError: Cannot read properties of undefined (reading 'Map')
    at e._initGL (MapBoxGLLayer.js:143:32)
    at e.onAdd (MapBoxGLLayer.js:42:10)
    at e._layerAdd (Layer.js:114:8)
    at e.whenReady (Map.js:1477:13)
    at e.addLayer (Layer.js:172:8)
    at e.addTo (Layer.js:52:7)
    at e._asyncAdd (VectorBasemapLayer.js:180:20)
    at e.onAdd (VectorBasemapLayer.js:133:12)
    at e._layerAdd (Layer.js:114:8)
    at e.whenReady (Map.js:1477:13)
_

System Info

Leaflet version: 1.9.3
Esri Leaflet version: 3.0.10
Esri Leaflet Vector version: 3.1.5
Maplibre GL JS version: 2.3.0

Additional Information

No response

gavinr commented 1 year ago

It does work fine if i use the correct recent version of Esri Leaflet Vector: https://jsbin.com/xajulajusa/edit?html,output