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);
上一篇:MySQL分库分表之Sharding-JDBC第二篇


下一篇:定位