How to determine the viewer's current zoom level?

I’m having trouble finding out how to determine the user’s current zoom level; as in the zoom level that will be used to fetch tiles.

Could anyone please help point me in the right direction?

Hey Brian,

There is no single “current zoom level” that the engine uses. This is because the level of detail of tiles fetched depends on its distances to the camera, so if you tilt the camera to see the horizon, the viewer is simultaneously loading tiles of the highest zoom level down to the lowest. This is what allows the CesiumJS viewer to tilt the camera beyond the 45 degree limit that you might typically run into.

I’m curious to hear more about what you’re trying to accomplish.

By the way, I wanted to say I appreciate the contributions you’ve been making in the community (also onXmaps looks awesome!)

Ah that makes perfect sense Omar! Thanks for the explanation.

To give some background, I’m using Cesium.sampleTerrain() and rather than sample at some hard-coded level, someone on my team thought it would be nice to be able to sample at whatever level the user was at. In this case, I really only need to know the highest level we would render when the camera is looking straight down from a specific height, since I’m sampling the terrain directly below the camera. It works fine as is, was just wondering if I could be smarter about sampling the terrain given the camera position.

Also, I’m glad to help when I can. This has been a really pleasant environment to work in. Both the Cesium staff and the community you have all build around this awesome product is wonderful. Keep up the great work!

1 Like