Cesium 当前相机视角
作者:互联网
var arrLoc = [];
var pickPosition = { x: null, y: null }
var handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas); //定义事件
handler.setInputAction(function (movement) {
// screenLocation.x = movement.position.x;
// screenLocation.y = movement.position.y;
var cartesian = viewer.camera.pickEllipsoid(
movement.position,
scene.globe.ellipsoid
);
if (cartesian) {
var cartographic = Cesium.Cartographic.fromCartesian(cartesian);
var longitudeString = Cesium.Math.toDegrees(
cartographic.longitude
).toFixed(2); //要更高的精度就修改保留的小数位数
var latitudeString = Cesium.Math.toDegrees(
cartographic.latitude
).toFixed(2); //同上
pickPosition.x = longitudeString;
pickPosition.y = latitudeString;
let cf = { x: parseFloat(pickPosition.x), y: parseFloat(pickPosition.y) }
console.log(cf) //鼠标点击位置
var a = {
position: viewer.camera.position,
heading: viewer.camera.heading,
pitch: viewer.camera.pitch
}
console.log(a) //当前视角
}
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
标签:视角,pickPosition,viewer,相机,var,Cesium,position,movement 来源: https://www.cnblogs.com/hustshu/p/15558048.html