[GIS] How to control the zoom amount in Cesium.Camera.flyTo

cesiumzoom

The following code flies the camera to a particular destination. But how do I control the zoom on the particular destination?

   viewer.camera.flyTo({
      destination : Cesium.Cartesian3.fromDegrees(-117.16, 32.71, 15000.0),
      duration : 20.0
    }); 

Changing Cesium.Camera.defaultZoomAmount doesn't seem to work for me.

Best Answer

The destination is allowed to be a Rectangle instead of a Cartesian3. When using a rectangle, the camera's height (zoom level) will be set such that it can see the corners of the rectangle. Use a larger rectangle for a more zoomed-out look.

For a working example of this, load the Sandcastle Camera Demo and click the pull-down to select "Fly to Rectange". The demo runs this code:

var west = -90.0;
var south = 38.0;
var east = -87.0;
var north = 40.0;
var rectangle = Cesium.Rectangle.fromDegrees(west, south, east, north);

viewer.camera.flyTo({
    destination : rectangle
});

// Show the rectangle.  Not required; just for show.
viewer.entities.add({
    rectangle : {
        coordinates : rectangle,
        fill : false,
        outline : true,
        outlineColor : Cesium.Color.WHITE
    }
});