wangzhibo
2021-09-06 2efb5d2a02ce47a9fd6f1cec138496aba72f0815
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
(function (window, mars3d) {
  //创建widget类,需要继承BaseWidget
  class MyWidget extends mars3d.widget.BaseWidget {
    //弹窗配置
    get view() {
      return {
        type: "window",
        url: "view.html",
        windowOptions: {
          width: 250,
          height: 270,
        },
      };
    }
    //初始化[仅执行1次]
    create() {
      this.floodByGraphic = new mars3d.thing.FloodByGraphic({
        style: {
          color: "#007be6",
          opacity: 0.5,
          outline: false,
        },
      });
      this.map.addThing(this.floodByGraphic);
 
      this.floodByGraphic.on(mars3d.EventType.change, (e) => {
        //分析中,高度变化了
        if (this.viewWindow) {
          this.viewWindow.onChangeHeight(e.height);
        }
      });
    }
    //每个窗口创建完成后调用
    winCreateOK(opt, result) {
      this.viewWindow = result;
    }
    //打开激活
    activate() {}
    //关闭释放
    disable() {
      this.viewWindow = null;
      this.clear();
    }
    drawPolygon() {
      this.clear();
      this.map.graphicLayer.startDraw({
        type: "polygon",
        style: {
          color: "#007be6",
          opacity: 0.5,
          outline: false,
        },
        success: (graphic) => {
          var positions = graphic.positionsShow;
          this.map.graphicLayer.clear();
          this.drawOk(positions);
        },
      });
    }
    drawOk(positions) {
      if (this.viewWindow == null) {
        return;
      }
      haoutil.loading.show();
 
      var result = mars3d.PolyUtil.getHeightRange(positions, this.map.scene); //求最大、最小高度值
      this.viewWindow.updateHeightForDraw(result.minHeight, result.maxHeight);
 
      this.floodByGraphic.positions = positions;
 
      haoutil.loading.hide();
    }
 
    clear() {
      this.floodByGraphic.clear();
      this.map.graphicLayer.clear();
    }
  }
 
  //注册到widget管理器中。
  mars3d.widget.bindClass(MyWidget);
 
  //每个widet之间都是直接引入到index.html中,会存在彼此命名冲突,所以闭包处理下。
})(window, mars3d);