question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Event for when a tile has loaded

See original GitHub issue

Would 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:open
  • Created 6 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
icemagnocommented, Oct 4, 2019

Ok. It will be nice to have a “per layer” tiles loading. Just like this global event.

0reactions
OmarShehatacommented, Oct 3, 2019

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Event for when a tile has loaded · Issue #5572 - GitHub
This event fires every time any new tile is loaded as shown in this Sandcastle example. If this is not what you're seeing...
Read more >
Tile Load Events - OpenLayers
Example using tile load events. Image tile sources fire events related to tile loading. You can listen for tileloadstart , tileloadend , and...
Read more >
Tile Loading Event - Google Groups
We don't have a way of checking whether an individual tile has been loaded, but you can manually look through the TileLoadQueue if...
Read more >
Mapbox event when brand new tile is loaded - Stack Overflow
I'm using Mapbox GL JS API to manipulate a Mapbox map. My question if there's an event that's capable ...
Read more >
Tile load events example
Image tile sources fire events related to tile loading. You can listen for tileloadstart , tileloadend , and tileloaderror type events to monitor...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found