cesium 实现卷帘

这里需要ImageryLayer 定义
参考 cesium 图层那些事

```javascript
/**

  • 卷帘效果
    */

import {ImageryLayer} from "./ImageryLayer";

export class ShutterEffect {
private map: any;
private _wrapper: any;
private _splitter: any;
private _splitterWidthCenter: any;
private _moveActive: boolean = false;
private _handler: any = null;
private _leftImageryLayer :ImageryLayer|null = null;
private _rightImageryLayer :ImageryLayer|null = null;
constructor(map: any) {
this.map = map;
this.moveHandler = this.moveHandler.bind(this);
}

  • start(left:ImageryLayer|null,right?:ImageryLayer|null,splitPosition = 0.5) {
  • this.stop();
  • if(this._wrapper || this._handler){
  • return;
  • }
  • if(left){
  • this._leftImageryLayer = left;
  • left.splitDirection(Cesium.ImagerySplitDirection.LEFT);
  • }
  • if(right){
  • this._rightImageryLayer = right;
  • right.splitDirection(Cesium.ImagerySplitDirection.RIGHT);
  • }
  • this.createDom(splitPosition);
  • }
  •  
  • stop() {
  • if (this._handler) {
  • this._handler.destroy();
  • this._handler = null;
  • }
  • if(this._wrapper){
  • this.map.container.removeChild(this._wrapper);
  • this._wrapper = null;
  • }
  • if(this._leftImageryLayer){
  • this._leftImageryLayer.removeByMap();
  • }
  • if(this._rightImageryLayer){
  • this._rightImageryLayer.removeByMap();
  • }
posted @ 2022-01-20 17:50  haibalai  阅读(393)  评论(0编辑  收藏  举报