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
"use script"; //开发环境建议开启严格模式
(function (window, mars3d) {
  //创建widget类,需要继承BaseWidget
  class MyWidget extends mars3d.widget.BaseWidget {
    //弹窗配置
    get view() {
      return {
        type: "window",
        url: "view.html",
        windowOptions: {
          width: 220,
          height: 440,
        },
      };
    }
 
    //初始化[仅执行1次]
    create() {
      //用于显示查询结果(geojson)的图层
      this.geoJsonLayer = new mars3d.layer.GeoJsonLayer({
        name: this.config.name,
        pid: 99, //图层管理 中使用,父节点id
        symbol: {
          type: "polygon",
          styleOptions: {
            fill: true,
            color: "rgb(2,26,79)",
            opacity: 0.4,
            outline: true,
            outlineColor: "#39E09B",
            outlineWidth: 6,
            outlineOpacity: 0.8,
            arcType: Cesium.ArcType.GEODESIC,
            clampToGround: true,
          },
        },
        popup: "{name}",
      });
    }
    //每个窗口创建完成后调用
    winCreateOK(opt, result) {
      this.viewWindow = result;
    }
    //打开激活
    activate() {
      this.geoJsonLayer.on(mars3d.EventType.load, this.geoJsonLayer_onLoadHandler, this);
      this.map.addLayer(this.geoJsonLayer);
    }
    //关闭释放
    disable() {
      this.geoJsonLayer.clear();
 
      this.geoJsonLayer.off(mars3d.EventType.load, this.geoJsonLayer_onLoadHandler, this);
      this.map.removeLayer(this.geoJsonLayer);
 
      this.viewWindow = null;
    }
    showRegionExtent(geojson) {
      this.geoJsonLayer.clear();
      this.geoJsonLayer.load({ data: geojson });
    }
    geoJsonLayer_onLoadHandler(event) {
      // event.list
      this.geoJsonLayer.flyTo();
    }
    goHome() {
      this.geoJsonLayer.clear();
      this.map.flyHome();
    }
  }
 
  //注册到widget管理器中。
  mars3d.widget.bindClass(MyWidget);
 
  //每个widet之间都是直接引入到index.html中,会存在彼此命名冲突,所以闭包处理下。
})(window, mars3d);