setView

Sets the camera position, orientation and transform.

// 1. Set position with a top-down view
viewer.camera.setView({
    destination : Cartesian3.fromDegrees(-117.16, 32.71, 15000.0)
});

// 2 Set view with heading, pitch and roll
viewer.camera.setView({
    destination : cartesianPosition,
    orientation: {
        heading : Math.toRadians(90.0), // east, default value is 0.0 (north)
        pitch : Math.toRadians(-90),    // default value (looking down)
        roll : 0.0                             // default value
    }
});

// 3. Change heading, pitch and roll with the camera position remaining the same.
viewer.camera.setView({
    orientation: {
        heading : Math.toRadians(90.0), // east, default value is 0.0 (north)
        pitch : Math.toRadians(-90),    // default value (looking down)
        roll : 0.0                             // default value
    }
});

// 4. View rectangle with a top-down view
viewer.camera.setView({
    destination : Rectangle.fromDegrees(west, south, east, north)
});

// 5. Set position with an orientation using unit vectors.
viewer.camera.setView({
    destination : Cartesian3.fromDegrees(-122.19, 46.25, 5000.0),
    orientation : {
        direction : new Cartesian3(-0.04231243104240401, -0.20123236049443421, -0.97862924300734),
        up : new Cartesian3(-0.47934589305293746, -0.8553216253114552, 0.1966022179118339)
    }
});

See also