Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MapboxGL dataloading event never change property isSourceLoaded to true

I am trying to get the moment where my source is completely loaded to perform an action.
I am using Map#dataloading and waiting until isSourceLoaded becomes true, but this never happens.

I am using the listener like this:

map.on('dataloading', e => {
  if (e.dataType === 'source') {
    console.log(e)
  }
})

and the result

like image 763
thiagoxvo Avatar asked Sep 01 '25 09:09

thiagoxvo


1 Answers

I think you should be listening to the data event, and not the dataloading event, but even so there is a bug with the implementation of isSourceLoaded that is being tracked here https://github.com/mapbox/mapbox-gl-js/issues/3958. In the meantime, a workaround would be checking for map.style.sourceCaches["composite"].loaded() when the data event fires.

Hope this helps!

Disclaimer - I work at Mapbox

like image 86
mollymerp Avatar answered Sep 07 '25 07:09

mollymerp