cesium 监听滚轮获取屏幕四角坐标,视角高度,缩放等级

发布时间:2024年01月12日
//获取四角经纬度
export const fourWind = () => {
    // 获取当前视图范围
    var extent = viewer.camera.computeViewRectangle();

    // 提取四个角的经纬度
    var southwest = Cesium.Rectangle.southwest(extent);
    var southeast = Cesium.Rectangle.southeast(extent);
    var northeast = Cesium.Rectangle.northeast(extent);
    var northwest = Cesium.Rectangle.northwest(extent);
    return northwest
    // 打印经纬度信息
    console.log("Southwest Corner: " + Cesium.Math.toDegrees(southwest.longitude) + ", " + Cesium.Math.toDegrees(southwest.latitude));
    console.log("Southeast Corner: " + Cesium.Math.toDegrees(southeast.longitude) + ", " + Cesium.Math.toDegrees(southeast.latitude));
    console.log("Northeast Corner: " + Cesium.Math.toDegrees(northeast.longitude) + ", " + Cesium.Math.toDegrees(northeast.latitude));
    console.log("Northwest Corner: " + Cesium.Math.toDegrees(northwest.longitude) + ", " + Cesium.Math.toDegrees(northwest.latitude));
}

//监听鼠标滚轮事件
export const ScreenSpaceEventHandler = (callback) => {

    const handle3D = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
    handle3D.setInputAction(() => {
        console.log(fourWind(), 'yi1')
           // var level = Math.ceil(viewer.camera.positionCartographic.height);
        // console.log(level,'缩放等级')
         // var height = viewer.camera.positionCartographic.height;
        // console.log(height,'高度')
        callback(fourWind())
    }, Cesium.ScreenSpaceEventType.WHEEL);
}

文章来源:https://blog.csdn.net/Thekingyu/article/details/135548386
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。