Zoom to coordinates while keeping a certain height

1. A concise explanation of the problem you’re experiencing.

I wrote a code in order to zoom to a certain point. The problem is it goes underground and I need to manually zoom out, while I want to do it automatically (by setting altitude, something like that).

2. A minimal code example. If you’ve found a bug, this helps us reproduce and repair it.

var e = viewer.entities.add({
position : Cesium.Cartesian3.fromDegrees(10.649839138, 40.123856495),
point : {
verticalOrigin : Cesium.VerticalOrigin.BOTTOM
}
});

viewer.zoomTo(e);

3. Context. Why do you need to do this? We might know a better way to accomplish your goal.

I need to zoom to a point without going underground.

4. The Cesium version you’re using, your operating system and browser.

CesiumJS 1.60

Windows 7

Mozilla Firefox 68.0.2

1 Like

You can use the viewer.flyTo method (https://cesiumjs.org/Cesium/Build/Documentation/Viewer.html?classFilter=viewer#flyTo) which takes an entity, and a set of options, so you can control the height or angle offset from what the camera is flying to.

The zoomTo method also has a similar offset option (see https://cesiumjs.org/Cesium/Build/Documentation/Viewer.html?classFilter=viewer#zoomTo).

What kind of project are you working on?

1 Like

I solved my problem using the flyTo() method, thank you very much!

useful…