Przeglądaj źródła

add the resolution and viewBounds properties

tags/2.1.2
Caven Chen 4 lat temu
rodzic
commit
11db7c4eaa
1 zmienionych plików z 39 dodań i 0 usunięć
  1. 39
    0
      modules/viewer/Viewer.js

+ 39
- 0
modules/viewer/Viewer.js Wyświetl plik

@@ -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

Ładowanie…
Anuluj
Zapisz