Cesium.js How to get each tiles' level?

382 views
Skip to first unread message

Aaron Feng

unread,
Nov 3, 2015, 10:16:29 AM11/3/15
to cesium-dev

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.

Kevin Ring

unread,
Nov 3, 2015, 6:14:24 PM11/3/15
to cesiu...@googlegroups.com
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

--
You received this message because you are subscribed to the Google Groups "cesium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cesium-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Aaron Feng

unread,
Nov 3, 2015, 7:32:46 PM11/3/15
to cesiu...@googlegroups.com
Got it. Thank you very much.

--
You received this message because you are subscribed to a topic in the Google Groups "cesium-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cesium-dev/cIHbsAKnRa8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cesium-dev+...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Best regards,
Yuzhou Feng
Florida International University,
MS of Computer Science Engineering Management

Aaron Feng

unread,
Nov 9, 2015, 11:14:39 AM11/9/15
to cesium-dev
Thank you very much.

s.pla...@gmail.com

unread,
Feb 17, 2017, 6:20:24 AM2/17/17
to cesium-dev
And how i get it in WebMercatorTilingScheme?

Am Mittwoch, 4. November 2015 00:14:24 UTC+1 schrieb Kevin Ring:
> 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
>
>
> On Wed, Nov 4, 2015 at 2:16 AM, Aaron Feng <gghg...@gmail.com> wrote:
>
>
> 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
>
>
>
Reply all
Reply to author
Forward
0 new messages