| * | * | ||||
| * @private | * @private | ||||
| */ | */ | ||||
| _computeBounds(points) { | |||||
| _computeBounds() { | |||||
| Cesium.Rectangle.fromCartographicArray( | Cesium.Rectangle.fromCartographicArray( | ||||
| points.map((item) => Cesium.Cartographic.fromDegrees(item.lng, item.lat)), | |||||
| this._points.map((item) => Cesium.Cartographic.fromDegrees(item.lng, item.lat)), | |||||
| this._bounds | this._bounds | ||||
| ) | ) | ||||
| } | } | ||||
| _computeBoundsInMeter() { | _computeBoundsInMeter() { | ||||
| let swInMeter = WMP.project(Cesium.Rectangle.southwest(this._bounds)) | let swInMeter = WMP.project(Cesium.Rectangle.southwest(this._bounds)) | ||||
| let neInMeter = WMP.project(Cesium.Rectangle.northeast(this._bounds)) | let neInMeter = WMP.project(Cesium.Rectangle.northeast(this._bounds)) | ||||
| return new Cesium.Rectangle( | |||||
| this._boundsInMeter = new Cesium.Rectangle( | |||||
| swInMeter.x, | swInMeter.x, | ||||
| swInMeter.y, | swInMeter.y, | ||||
| neInMeter.x, | neInMeter.x, | ||||
| */ | */ | ||||
| setPoints(points) { | setPoints(points) { | ||||
| this._points = points | this._points = points | ||||
| this._computeBounds(points) | |||||
| let boundsInMeter = this._computeBoundsInMeter() | |||||
| if (!Cesium.Rectangle.equals(this._boundsInMeter, boundsInMeter)) { | |||||
| this._boundsInMeter = boundsInMeter | |||||
| } | |||||
| this._computeBounds() | |||||
| this._computeBoundsInMeter() | |||||
| if (this._viewer) { | if (this._viewer) { | ||||
| this._scale = Math.min( | this._scale = Math.min( | ||||
| Math.abs(this._boundsInMeter.west - this._boundsInMeter.east) / | Math.abs(this._boundsInMeter.west - this._boundsInMeter.east) / |