Cesium.js How to get each tiles' level?

I am trying to get each tiles’ rectangle and level in current view, and use these information to do some ajax request.

Now I have already got all rectangles through:

var tileRecangles = [];
var tilesToRender = viewer.scene.globe._surface.tileProvider._tilesToRenderByTextureCount;
    if (Cesium.defined(tilesToRender)) {
        for (var j = 0, len = tilesToRender.length; j < len; j++) {
            var quadTrees = tilesToRender[j];
            if (Cesium.defined(quadTrees)) {
                for (var i = 0; i < quadTrees.length; i++) {
                    tileRecangles.push(quadTrees[i].rectangle);
                }
            }
        }
    }

The question is how to get the level for each tiles? The value in red circles of this screenshot

Thanks.

Hi Aaron,

In your example, you can get the level from quadTrees[i].level. quadTrees is a bit misnamed, though… those are individual tiles in a quadtree.

You can also simplify it like this:

viewer.scene.globe._surface.forEachRenderedTile(function(tile) {

// tile.rectangle and tile.level are available here.

});

Please be aware that you’re depending on implementation details of Cesium with this code, and those details can and will break your code by changing from release to release.

Kevin

Got it. Thank you very much.

Thank you very much.

And how i get it in WebMercatorTilingScheme?