fuchengshen
2022-07-15 e1186e0c9c1a7a47454b73f9cddcf733dce30b32
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
'use script' //开发环境建议开启严格模式
    ;
(function (window, mars3d) {
    //创建widget类,需要继承BaseWidget
    class MyWidget extends mars3d.widget.BaseWidget {
  //       get resources(){
        //     return [
        //         'viewl.js'
        //     ]
        // }
        
        get view() {
            return {
                type: 'window',
                url: 'view.html',
                windowOptions: {
                    width: 400,
                    height:350,
                    position: {
                        top: 180,
                        right: 5,
                        bottom: 110
                    },
                },
            }
        }
        
        reloadData(new_taxi_sn) {
          this.viewWindow.resetStartQueryTaxiDataText(new_taxi_sn);
          this.taxi_sn = new_taxi_sn;
        
          if (this.startGraphic) {
            this.startGraphic.remove();
            this.startGraphic = null;
          }
          if (this.endGraphic) {
            this.endGraphic.remove();
            this.endGraphic = null;
          }
          this.routeLayer.clear();
        }
        //初始化[仅执行1次]
        create() {
        //图层管理使用的分组
        this.groupLayer = new mars3d.layer.GroupLayer({
          name: this.config.name,
          pid: 50, //图层管理 中使用,父节点id
        });
        
        //创建矢量数据图层
        this.pointLayer = new mars3d.layer.GraphicLayer({
          name: this.config.name + "-起止点",
        });
        this.groupLayer.addLayer(this.pointLayer); //加入分组
        
        this.routeLayer = new mars3d.layer.GraphicLayer({
          name: this.config.name + "-路线",
        });
        this.groupLayer.addLayer(this.routeLayer); //加入分组
        }
        
        openTest(word){
            console.log(word,"eee")
        }
        locateAndHighlight(lon, lat) {
            this.map.flyToPoint(Cesium.Cartesian3.fromDegrees(lon, lat, 0.2));
        }
 
    
        addTaxiReplayGraphic(points) {
        console.log("拿到了数据",points)
          this.startGraphic = new mars3d.graphic.BillboardEntity({
            position: points[0],
            style: {
              image: this.path + "img/start.png",
              scale:1.2,
              opacity:1,
              scaleByDistance_far:500,
              distanceDisplayCondition_far:500,
              scaleByDistance_farValue:0.5,
              scaleByDistance:true,
              visibleDepth:true,
              hasPixelOffset:false,
              distanceDisplayCondition:true,
            },
          });
          this.pointLayer.addGraphic(this.startGraphic);
        
          this.endGraphic = new mars3d.graphic.BillboardEntity({
            position: points[points.length - 1],
            style: {
              image: this.path + "img/end.png",
              scale:1.2,
              opacity:1,
              scaleByDistance_far:500,
              distanceDisplayCondition_far:500,
              scaleByDistance_farValue:0.5,
              scaleByDistance:true,
              visibleDepth:true,
              hasPixelOffset:false,
              distanceDisplayCondition:true,
            },
          });
          this.pointLayer.addGraphic(this.endGraphic);
          let graphic = new mars3d.graphic.PolylineEntity({
            positions: points,
            style: {
              width: 3,
              material: new mars3d.material.LineFlowMaterialProperty({
                color: Cesium.Color.AQUA,
                image: "./img/arrow2.png",
                repeat: new Cesium.Cartesian2(50, 1),
                speed: 40, //速度,建议取值范围1-100
              })
            },
          });
          this.routeLayer.addGraphic(graphic);
          this.routeLayer.flyTo();
        }
        setSingleTaxiReplayData(datas) {
          let data = datas;
        }
        //每个窗口创建完成后调用
        winCreateOK(opt, result) {
            this.viewWindow = result;
            console.log(result,"创建完成")
            this.taxi_sn = this.config.params.id;
            this.name = this.config.params.name;
            this.floor = this.config.params.floor;
            console.log(this.config)
            this.viewWindow.resetStartQueryTaxiDataText(this.taxi_sn);
        }
        
        //打开激活
        activate() {
            console.log("激活完成s")
             this.map.addLayer(this.groupLayer);
             console.log("添加完成")
        }
        //关闭释放
        disable() {
            console.log("释放完毕")
            if (this.startGraphic) {
              this.startGraphic.remove();
              this.startGraphic = null;
            }
            if (this.endGraphic) {
              this.endGraphic.remove();
              this.endGraphic = null;
            }
            this.map.removeLayer(this.groupLayer);
        }
 
    }
 
    //注册到widget管理器中。
    mars3d.widget.bindClass(MyWidget)
 
    //每个widet之间都是直接引入到index.html中,会存在彼此命名冲突,所以闭包处理下。
})(window, mars3d)