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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With