Get user's current zoom level

1321 views
Skip to first unread message

seyed...@noaa.gov

unread,
Apr 1, 2016, 2:27:18 PM4/1/16
to cesium-dev
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.

Hannah Pinkos

unread,
Apr 4, 2016, 10:13:45 AM4/4/16
to cesium-dev, seyed...@noaa.gov
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

seyed...@noaa.gov

unread,
Apr 4, 2016, 4:04:28 PM4/4/16
to cesium-dev, seyed...@noaa.gov

Awesome, thanks Hannah

dsh...@gmail.com

unread,
Jul 19, 2016, 11:52:08 AM7/19/16
to cesium-dev, seyed...@noaa.gov

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

Hannah Pinkos

unread,
Jul 20, 2016, 10:38:14 AM7/20/16
to cesium-dev, seyed...@noaa.gov, dsh...@gmail.com
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

sangl...@gmail.com

unread,
Jul 24, 2017, 12:07:40 AM7/24/17
to cesium-dev, seyed...@noaa.gov
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

Rachel Hwang

unread,
Jul 28, 2017, 10:59:10 AM7/28/17
to cesium-dev, seyed...@noaa.gov, sangl...@gmail.com
Hi Sang,


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

hope that helps,
- Rachel
Reply all
Reply to author
Forward
0 new messages