# Zoom event?

**URL:** <https://community.cesium.com/t/zoom-event/2688>\
**Category:** CesiumJS\
**Created:** [June 24, 2015, 10:03pm UTC](https://community.cesium.com/t/zoom-event/2688 "2015-06-24T22:03:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![gonen\_jerbi](https://avatars.discourse-cdn.com/v4/letter/g/919ad9/32.png) [@gonen\_jerbi](https://community.cesium.com/u/gonen_jerbi)\
**Post date:** [June 24, 2015, 10:03pm UTC](https://community.cesium.com/t/zoom-event/2688/1 "2015-06-24T22:03:18Z")

</div>

Hi there,  
I am looking for zoom in\zoom out event in cesium.  
is there any?

---

<div class="post-metadata">

**Author:** ![Matt\_Amato](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/matt_amato/32/1993_2.png) [@Matt\_Amato](https://community.cesium.com/u/Matt_Amato)\
**Post date:** [June 24, 2015, 10:17pm UTC](https://community.cesium.com/t/zoom-event/2688/2 "2015-06-24T22:17:11Z")

</div>

What exactly do you mean by zoomIn/zoomOut.

The Cesium camera can move and rotate at any angle and in any direction, so the concept of zoomIn/zoomOut as it is used in a 2D map is meaningless. Zoom-in in Cesium means the camera moved in a positive direction it is pointing, and zoom out means the negative direction. It has no relation to how close you are to the Earth or how much of the map is in view.

Assuming you simply want to know when the camera moves, you can use the camera.moveStart moveEnd events, of which there is an example here: [http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Camera.html&label=Showcases](http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Camera.html&label=Showcases)

If you want to know how close the camera is to the surface of the Earth, you can just get the camera’s height via camera.positionCartographic.height. his provides the height relative to the ellipsoid, not the terrain.

If you can explain in more detail what you are trying to do, we can make specific suggestions.

---

<div class="post-metadata">

**Author:** ![gonen\_jerbi](https://avatars.discourse-cdn.com/v4/letter/g/919ad9/32.png) [@gonen\_jerbi](https://community.cesium.com/u/gonen_jerbi)\
**Post date:** [June 25, 2015, 7:04am UTC](https://community.cesium.com/t/zoom-event/2688/3 "2015-06-25T07:04:39Z")

</div>

Thanks for the answer.  
The rotation of the camera in our project is disabled which means that there is no 2.5D.

By saying zoom in\zoom out i mean that the camera height has been changed.

Camera move is overspec for my situation - i just need to know when the camera height is changed.

Is there any event or any way to know this?

---

<div class="post-metadata">

**Author:** ![Matt\_Amato](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/matt_amato/32/1993_2.png) [@Matt\_Amato](https://community.cesium.com/u/Matt_Amato)\
**Post date:** [June 25, 2015, 1:02pm UTC](https://community.cesium.com/t/zoom-event/2688/4 "2015-06-25T13:02:35Z")

</div>

I still think the camera move events are the best way to handle this, just check the height in the callback. Otherwise you can listen to the preRender event and do it that way.

var viewer = new Cesium.Viewer(‘cesiumContainer’);

var scene = viewer.scene;

var lastHeight;

scene.preRender.addEventListener(function(){

var camera = scene.camera;

var height = camera.positionCartographic.height;

if(lastHeight !== height) {

//Camera height has changed

lastHeight = height;

}

});

---

<div class="post-metadata">

**Author:** ![gonen\_jerbi](https://avatars.discourse-cdn.com/v4/letter/g/919ad9/32.png) [@gonen\_jerbi](https://community.cesium.com/u/gonen_jerbi)\
**Post date:** [June 25, 2015, 8:24pm UTC](https://community.cesium.com/t/zoom-event/2688/5 "2015-06-25T20:24:36Z")

</div>

It seems that the height changes each time(the height from the surface changes each camera move).

---

<div class="post-metadata">

**Author:** ![Matt\_Amato](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/matt_amato/32/1993_2.png) [@Matt\_Amato](https://community.cesium.com/u/Matt_Amato)\
**Post date:** [June 29, 2015, 4:15pm UTC](https://community.cesium.com/t/zoom-event/2688/6 "2015-06-29T16:15:14Z")

</div>

Yes, that’s because the camera is rotating a fixed radius from the center of the earth, but the earth itself is an ellipsoid not a sphere. Having the camera rotate at a fixed height above the earth would create odd behavior and movement…
