wangzhibo
2021-12-04 ce1867b7f074df69f0c30112f988cb1590b50128
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
"use script"; //开发环境建议开启严格模式
(function (window, mars3d) {
  //创建widget类,需要继承BaseWidget
  class MyWidget extends mars3d.widget.BaseWidget {
    //弹窗配置
    get view() {
      return {
        type: "window",
        url: "view.html",
        windowOptions: {
          width: 500,
          height: 200,
        },
      };
    }
    //初始化[仅执行1次]
    create() {}
    //每个窗口创建完成后调用
    winCreateOK(opt, result) {
      this.viewWindow = result;
    }
    //打开激活
    activate() {
      if (this.viewWindow) {
        this.viewWindow.setEchartsData(this.config.data);
      }
    }
    //内置方法,不重启方式刷新页面
    update() {
      if (this.viewWindow) {
        this.viewWindow.setEchartsData(this.config.data);
      }
    }
    //关闭释放
    disable() {
      this.viewWindow = null;
      this.hideTipMarker();
    }
 
    showTipMarker(point, z, inthtml) {
      var _position_draw = Cesium.Cartesian3.fromDegrees(point.lng, point.lat, z);
 
      if (!this.tipGraphic) {
        this.tipGraphic = new mars3d.graphic.BillboardEntity({
          name: "当前点",
          position: _position_draw,
          style: {
            image: "img/marker/mark3.png",
            scale: 1,
            horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
            verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
            scaleByDistance: new Cesium.NearFarScalar(10000, 1.0, 500000, 0.2),
          },
        }).addTo(this.map.graphicLayer);
        this.tipGraphic._setPositionsToCallback();
      }
      this.tipGraphic._position_draw = _position_draw;
      this.tipGraphic
        .bindPopup(inthtml, {
          anchor: [0, -20], //左右、上下的偏移像素值。
        })
        .openPopup();
    }
 
    hideTipMarker() {
      if (!this.tipGraphic) {
        return;
      }
      this.tipGraphic.remove(true);
      this.tipGraphic = null;
    }
  }
 
  //注册到widget管理器中。
  mars3d.widget.bindClass(MyWidget);
 
  //每个widet之间都是直接引入到index.html中,会存在彼此命名冲突,所以闭包处理下。
})(window, mars3d);