flyTo(过渡定位)
const viewer = new Cesium.Viewer('CesiumBox');
let params = {
lon: 119.98,
lat: 30.22,
alt: 0,
heading: Cesium.Math.toRadians(60.0),
pitch: Cesium.Math.toRadians(30.0),
roll: 0.0,
range: 5000.0
};
viewer.camera.flyTo({
// fromDegrees()将经纬度和高程转换为世界坐标
destination: Cesium.Cartesian3.fromDegrees(params.lon, params.lat, params.alt),
orientation: {
// 指向
heading: params.heading,
// 视角
pitch: params.pitch,
roll: params.roll
}
});
setView(直接定位)
const viewer = new Cesium.Viewer('CesiumBox');
viewer.camera.setView({
destination : Cesium.Cartesian3.fromDegrees(109.435314,34.960521, 15000.0), // 设置位置
orientation: {
heading : Cesium.Math.toRadians(20.0), // 方向
pitch : Cesium.Math.toRadians(-90.0),// 倾斜角度
roll : 0
}
});
lookAt(直接定位)
const viewer = new Cesium.Viewer('CesiumBox');
let params = {
lon: 119.98,
lat: 30.22,
alt: 0,
heading: Cesium.Math.toRadians(60.0),
pitch: Cesium.Math.toRadians(30.0),
roll: 0.0,
range: 5000.0
};
let destination = Cesium.Cartesian3.fromDegrees(params.lon, params.lat, params.alt);
let orientation = new Cesium.HeadingPitchRange(params.heading, params.pitch, params.range);
viewer.scene.camera.lookAt(destination, orientation);
注意:lookAt这种方式无法用鼠标滚轮切换视角,而flyTo可以。