Get user's current zoom level

I know I can get the user's magnitude to the core of earth, however is there a way to get the current zoom level?

I figure if there's no clustering:
https://groups.google.com/forum/#!topic/cesium-dev/_GTmHu7AWvo

then I can use the current zoom level to cluster a collection of PointPrimitives myself.

Hello,

You can get the distance in meters between the camera and the ellipsoid surface like this:

var cameraPosition = viewer.scene.camera.positionWC;
var ellipsoidPosition = viewer.scene.globe.ellipsoid.scaleToGeodeticSurface(cameraPosition);
var distance = Cesium.Cartesian3.magnitude(Cesium.Cartesian3.subtract(cameraPosition, ellipsoidPosition, new Cesium.Cartesian3()));

``

Best,

Hannah

Awesome, thanks Hannah

Hello,

The code works great in 3D scene mode, but in SCENE2D return invalid results.
Should i use different calculation for geting the camera's heigth in this case?
Finally i want to calculate the map's scale represented in 2D view.

Best Regards,

Dima

Hello Dima,

The problem you’re seeing may be related to this issue: https://github.com/AnalyticalGraphicsInc/cesium/issues/3845

positionWC seems like it might be the incorrect value in 2D. Hopefully we’ll look into this soon.

Best,

Hannah

Hi Hannah,

For example, i have the zoom level range from 10 - 18 along with 10:20000m - 18:1000m of distance, so now if the camera is currently on 6000m of height, please help me to compute the zoom level of this height and what algorithm to compute it?

Thanks
Sang

Hi Sang,

See this thread: https://groups.google.com/forum/?hl=en#!searchin/cesium-dev/zoom$20level|sort:relevance/cesium-dev/QG2EbfMl43k/YII7A7OwBwAJ

The ImageryLayer API will help you. For instance, you can use maximumLevel and minimumLevel to clamp the zoom levels used.

http://cesiumjs.org/Cesium/Build/Documentation/ImageryProvider.html?classFilter=imagery

hope that helps,

  • Rachel