Event for when a tile has loaded
See original GitHub issueWould like an event listener for when a slippy tile has loaded. I’m trying to keep track of our calls to a map tile server, since that API doesn’t provide a counter for how many requests we’ve done. I’ve almost gotten something hacked together using the _requestImagery function of ImageryLayer, but it is hard to do without modifying the source code, especially since _requestImagery doesn’t return a promise or take a callback. If it did, I could at least check for ImageryState.Received.
The way I’m having to currently do it, I don’t think is totally foolproof.
let layer = layers.addImageryProvider(new Cesium.createOpenStreetMapImageryProvider({
url: url,
}));
layer._requestImagery = function(imagery) {
Cesium.ImageryLayer.prototype._requestImagery.call(this, imagery);
if(imagery.state === Cesium.ImageryState.TRANSITIONING) {
num_api_calls++;
}
};
Since the images are being requested asynchronously, it isn’t possible to just check for ImageryState.RECEIVED right after the call. The best I can do is check for TRANSITIONING instead of UNLOADED, but there is still the chance it could go back to UNLOADED if too many images are being requested concurrently. Surprisingly, my num_api_calls is actually decently accurate, reporting 1779 requests when actual was 1766.
I think this could be solved by having a public event that fires when the imagePromise in ImageryState.js has been resolved.
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (3 by maintainers)

Top Related StackOverflow Question
Ok. It will be nice to have a “per layer” tiles loading. Just like this global event.
@cguldner I’m closing this because it looks like this could be accomplished with the given event, and there is also a helper class that keeps track of requests that you might find useful as a reference here:
https://github.com/AnalyticalGraphicsInc/cesium/blob/de92ad61bfa764206faf6ffd904cea733d86bbca/Apps/Sandcastle/gallery/development/Terrain Performance.html#L36
Feel free to follow up here if I misunderstood what you’re trying to do.