cesium 分屏对比 多窗同步
程序员文章站
2022-06-09 19:06:01
不说废话, 代码// 视图同步this.leftViewer.eventManager.addCameraMoveListener(e => {if (this.isLeft() && this.synchronous) {const viewPoint = this.leftViewer.getViewPoint()this.rightViewer.baseViewer.camera.setView({destination: vi...
不说废话, 代码
// 视图同步
this.leftViewer.eventManager.addCameraMoveListener(e => {
if (this.isLeft() && this.synchronous) {
const viewPoint = this.leftViewer.getViewPoint()
this.rightViewer.baseViewer.camera.setView({
destination: viewPoint.position,
orientation: viewPoint.orientation
})
}
})
this.rightViewer.eventManager.addCameraMoveListener(e => {
if (!this.isLeft() && this.synchronous) {
const viewPoint = this.rightViewer.getViewPoint()
this.leftViewer.baseViewer.camera.setView({
destination: viewPoint.position,
orientation: viewPoint.orientation
})
}
})
获取相机位置
/**
* 获取相机位置及旋转角度
* @return {{orientation: {heading: number, roll: number, pitch: number}, position: Cesium.Cartesian3}}
*/
getViewPoint() {
return {
position: this.baseViewer.camera.position.clone(),
orientation: {
heading: this.baseViewer.camera.heading,
pitch: this.baseViewer.camera.pitch,
roll: this.baseViewer.camera.roll
}
}
}
监听move, 看鼠标在哪边
// 记忆是哪一边在操作
this.leftViewer.eventManager.addEventListener(EventConstant.MOUSE_MOVE, e => {
this.currentOperation = ManyWindowViewer.LEFT_VIEWER
})
this.rightViewer.eventManager.addEventListener(EventConstant.MOUSE_MOVE, e => {
this.currentOperation = ManyWindowViewer.RIGHT_VIEWER
})
/**
* 是否操纵左边
* @return {boolean}
*/
isLeft() {
return this.currentOperation === ManyWindowViewer.LEFT_VIEWER
}
本文地址:https://blog.csdn.net/d351064378/article/details/114298976
上一篇: Python基础之面向对象进阶详解
下一篇: 详解c# 事件总线