浏览代码

add the resolution and viewBounds properties

tags/2.1.2
Caven Chen 4 年前
父节点
当前提交
11db7c4eaa
共有 1 个文件被更改,包括 39 次插入0 次删除
  1. 39
    0
      modules/viewer/Viewer.js

+ 39
- 0
modules/viewer/Viewer.js 查看文件

@@ -135,6 +135,45 @@ class Viewer {
return position
}

get resolution() {
let width = this.scene.canvas.width
let height = this.scene.canvas.height
let min = Transform.transformWindowToWGS84(
new Cesium.Cartesian2((width / 2) | 0, height - 1),
this
)
let max = Transform.transformWindowToWGS84(
new Cesium.Cartesian2((1 + width / 2) | 0, height - 1),
this
)
if (!min || !max) {
return undefined
}
return Math.abs(min.lng - max.lng)
}

get viewBounds() {
let width = this.scene.canvas.width
let height = this.scene.canvas.height
let min = Transform.transformWindowToWGS84(
new Cesium.Cartesian2(0, height),
this
)
let max = Transform.transformWindowToWGS84(
new Cesium.Cartesian2(width, 0),
this
)
if (!min || !max) {
return undefined
}
return {
minX: min.lng,
minY: min.lat,
maxX: max.lng,
maxY: max.lat
}
}

/***
*
* @param layerGroup

正在加载...
取消
保存