Esri / esri-leaflet-vector

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

'load' and 'loading' events not firing on vectorBasemapLayer #104

Closed mariocasciaro closed 2 years ago

mariocasciaro commented 3 years ago

With L.esri.basemapLayer it's currently possible to get notified when all tiles are finished loading by listening to the 'load' event. Similarly, when tiles start loading, the 'loading' event is fired. Those events are not fired when using L.esri.Vector.vectorBasemapLayer. Is there any plan to add those events?

jwasilgeo commented 3 years ago

@mariocasciaro are you asking about L.esri.basemapLayer or one of the layer types in this plugin? https://github.com/Esri/esri-leaflet-vector#api-reference

mariocasciaro commented 3 years ago

Sorry, my mistake. I updated the original post. I was referring to L.esri.Vector.vectorBasemapLayer.

jwasilgeo commented 3 years ago

No worries, thanks for clarifying.

Right now we do not fire events on the layer instance for both L.esri.Vector.vectorBasemapLayer and L.esri.Vector.vectorTileLayer; however, (at your own risk) you could try any of these mapbox-gl-js map instance events ( https://docs.mapbox.com/mapbox-gl-js/api/map/#events-data-loading) by accessing like this in your code:

var layer = L.esri.Vector.vectorBasemapLayer("ArcGIS:Streets", {
  apiKey: "YOUR KEY HERE"
});

layer.addTo(map);

// access the internal instance of the mapbox-gl-js map like this
// and attach your own listeners such as "styledata", "dataloading", etc.
layer._mapboxGL._glMap.on('styledata', function (e) { 
  console.log(e);
});
mariocasciaro commented 3 years ago

Thanks @jwasilgeo I'll give that a try.

shawnmgoulet commented 2 years ago

@mariocasciaro are we clear to close this issue after Jacob's suggestion or do we need to leave it open for further exploration? If so, could you provide additional context? Thanks!

mariocasciaro commented 2 years ago

Sure, we can close this for now. I will reopen it if we will encounter any issues with the mapbox-gl events.