Ballon Ura
Ballon Ura

Reputation: 922

Mapbox event when brand new tile is loaded

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 ?
   }
  });

Im using this & this docs

Upvotes: 0

Views: 532

Answers (1)

Steve Bennett
Steve Bennett

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

Related Questions