美文网首页
cesium 实现卷帘

cesium 实现卷帘

作者: haibalai | 来源:发表于2022-08-11 15:24 被阅读0次

    这里需要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();

    }

     更多参考 

    相关文章

      网友评论

          本文标题:cesium 实现卷帘

          本文链接:https://www.haomeiwen.com/subject/cyaxgrtx.html