Reputation: 922
I'm using Mapbox GL JS API to manipulate a Mapbox map. My question if there's an event that's capable of telling me for each HTTP request for new tile? I finish with a code like this:
map.on("dataloading", e => {
if(e.dataType === "source" && e.source.url && e.tile) {
//Fresh HTTP request to Mapbox API ?
}
});
Upvotes: 0
Views: 532
Reputation: 126105
It's not the primary purpose, but you should be able to use map.transformRequest
to achieve this goal. It gets called for every request, so you'll just have to check whether it's loading a tile or something else.
Upvotes: 1