13693261870
2023-06-21 cdf12fc9e88b1af69f5c85165eb9fef4e23bf57a
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
<!DOCTYPE>
 
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width,initial-scale=1.0">
  <title>经济运行</title>
  <style>
    html,
    body {
      width: 100%;
      height: 100%;
      padding: 0;
      margin: 0;
      overflow: hidden;
      font-size: 13px;
      font-family: 微软雅黑;
    }
 
    #map {
      width: 100%;
      height: 100%;
      position: absolute;
    }
 
    #ctrl {
      position: absolute;
      left: 10px;
      top: 10px;
      z-index: 1;
    }
  </style>
  <script src="./UE/jquery.min.js"></script>
  <script src="./UE/tumap.js"></script>
  <script src="./config/config.js"></script>
  <script>
        var UE = {
            bs: [],
 
            is: [],
 
            map: null,
 
            isLocal: true,
 
            // 1 经济-大屏-楼宇产业
            cyUrl: "sql/data/api/v2/execute/customResult/SA2022060121160107332438/data",
 
            // 2 经济-大屏-产业楼宇列表
            lvUrl: "sql/data/api/v2/execute/customResult/SA2022060121192008197605/data",
 
            // 3 企业的列表
            qyUrl: "sql/data/api/v2/execute/customResult/SA2022060121220407301036/data",
 
            mainUrl: location.href.substring(0, location.href.lastIndexOf("/") + 1),
 
            // 初始化路径点
            views: [
              { x: -451552.65625, y: -376972.75, z: 0, roll: 0, pitch: -42.39, yaw: -71, distance: 1000000 },
              //{ x: -665329.3125, y: -875234.75, z: 0, roll: 0, pitch: -38.47, yaw: -3.88, distance: 411583 },
              //{ x: -526615.5, y: -991973.625, z: 0, roll: 0, pitch: -36.18, yaw: -289.5, distance: 242204 },
              //{ x: -562893.25, y: -954911.75, z: 0, roll: 0, pitch: -34.83, yaw: -126, distance: 67857 }
              { x: -625507.4375, y: -1002755.875, z: 0, roll: 0, pitch: -46.3, yaw: -90.7, distance: 367489 },
              { x: -625507.4375, y: -1002755.875, z: 0, roll: 0, pitch: -42.12, yaw: -8.9, distance: 152726 },
              { x: -613594.9375, y: -1013538.3125, z: 0, roll: 0, pitch: -37.8, yaw: -301.5, distance: 41097 }
            ],
 
            // 初始化
            init: function () {
                var that = this;
                this.map = new TUMap({
                    id: "map",
                    url: UE_URL,
                    onInit: function () {
                        that.inited();
                    }
                });
            },
 
            // 初始化完成
            inited: function () {
                var that = this;
                this.setView(this.views[0]);
                this.playRoute();
                this.map.setWeather("sun");
                this.map.setTime(12.0) ;
                this.map.pickPosition(function (e) {
                    if (e && e.category == "billboard" && e.clickType == 1 && e.data) {
                        that.flyToImg(e.data.x, e.data.y);
                    }
                });
            },
 
            // 播放路径
            playRoute: function () {
                var idx = 0, that = this;
                var timer = setInterval(function () {
                    idx++;
                    if (idx >= that.views.length) {
                        clearInterval(timer);
                        return;
                    }
 
                    that.flyTo(that.views[idx]);
                }, 3300);
            },
 
            // 定位
            setView: function (v) {
                // x, y, z, roll, pitch, yaw, distance, callBack, time
                this.map.setView(v.x, v.y, v.z, v.roll, v.pitch, v.yaw, v.distance);
            },
 
            // 飞向
            flyTo: function (v) {
                // x, y, z, roll, pitch, yaw, distance, callBack, time
                this.map.flyTo(v.x, v.y, v.z, v.roll, v.pitch, v.yaw, v.distance, null, 4);
            },
 
            // 飞向图片
            flyToImg: function (x, y, distance) {
                var p = this.map.transformWGS84ToLocal(x, y);
                // x, y, z, roll, pitch, yaw, distance, callBack, time
                this.map.flyTo(p.x, p.y, 0, 0, -42, 0, distance || 60000, null, 2);
            },
 
            // 移除广告牌
            removeBillboards: function (arr) {
                arr.forEach(function (b) {
                    b.removeFromMap()
                })
                arr.length = 0
            },
 
            // 获取产业信息
            getCY: function () {
                //console.log(this.getHost() + this.cyUrl);
                this.ajax(this.cyUrl, "POST", null, "json", null, function (data) {
                    //console.log(data);
                    if (!data || !data.length) return;
 
                    for (var i = 0, c = data.length; i < c; i++) {
                        $("#cySelect").append("<option value='" + data[i].industry_name + "'>" + data[i].industry_name + "</option>");
                    }
                });
            },
 
            cyChange: function (e) {
                var val = $("#cySelect option:selected").val();
 
                $("#cydSelect option[value!='']").remove();
                this.removeBillboards(this.is);
                this.removeBillboards(this.bs);
                if (!val) return;
 
                var that = this;
                var data = JSON.stringify({ "industry_name": val });
                this.ajax(this.lvUrl, "POST", data, "json", null, function (data) {
                    //console.log(data);
                    if (!data || !data.length) return;
 
                    that.loadCY(data);
                    that.flyToData(data);
                });
            },
 
            // 加载产业点
            loadCY: function (data) {
                for (var i = 0, c = data.length; i < c; i++) {
                    if (!data[i].lng || !data[i].lat) continue;
 
                    var p = this.map.transformWGS84ToLocal(data[i].lng, data[i].lat);
                    var bb = this.map.createBillboard({
                        x: p.x,
                        y: p.y,
                        z: 10,
                        image: this.mainUrl + "UE/img/cy1.png",
                        scale: 0.5,
                        clickedScale: 0.5,
                        visibility: true,
                        flash: false,
                        canClick: true,
                        //data: data[i],
                        alertWindow: {
                            url: this.mainUrl + "popupTwo.html?name=" + data[i].name + "&gdp=" + data[i].industrial_output, // 弹窗地址
                            size: new TUVector2(120, 50), // 弹窗大小
                            offset: new TUVector2(10, -65) // 弹窗位置,右:x正,下:y正
                        }
                    })
                    this.is.push(bb);
 
                    $("#cydSelect").append("<option value='" + data[i].id + "'>" + data[i].name + "</option>");
                }
            },
 
            flyToData: function (data) {
                var minX = 180, minY = 90, maxX = 0, maxY = 0;
                for (var i = 0, c = data.length; i < c; i++) {
                    var x = data[i].lng, y = data[i].lat;
                    if (!x || !y) continue;
 
                    if (x > maxX) maxX = x;
                    if (y > maxY) maxY = y;
                    if (x < minX) minX = x;
                    if (y < minY) minY = y;
                }
 
                var cx = (minX + maxX) / 2;
                var cy = (minY + maxY) / 2;
                var p = this.map.transformWGS84ToLocal(cx, cy);
 
                this.map.flyTo(p.x, p.y, 0, 0, -42, 0, 500000, null, 3);
            },
 
            // 产业点
            cydChange: function (e) {
                var val = $("#cydSelect option:selected").val();
 
                this.removeBillboards(this.bs);
                if (val == '') return;
 
                var that = this;
                var data = JSON.stringify({ "id": val });
                this.ajax(this.qyUrl, "POST", data, "json", null, function (data) {
                    console.log(data);
                    if (!data) return;
 
                    that.lyCope(data);
                });
            },
 
            // 楼宇
            lyCope: function (data) {
                var p = this.map.transformWGS84ToLocal(data.lng, data.lat);
                this.map.flyTo(p.x, p.y, 0, 0, -42, 0, 7500, null, 3);
 
                var bb = this.map.createBillboard({
                    x: p.x,
                    y: p.y,
                    z: 1000,
                    image: this.mainUrl + "UE/img/ly1.png",
                    scale: 1,
                    clickedScale: 1,
                    visibility: true,
                    flash: false,
                    canClick: true,
                    //data: data[i],
                    alertWindow: {
                        url: this.mainUrl + "popupOne.html?name=" + data.name + "&mode=" + data.mode_of_operation + "&unit=" + data.development_unit + "&output=" + data.industrial_output + "&usage=" + data.land_usage + "&rate=" + data.vacancy_rate + "&num=" + data.enterprise_num, // 弹窗地址
                        size: new TUVector2(300, 200), // 弹窗大小
                        offset: new TUVector2(-150, -170) // 弹窗位置,右:x正,下:y正
                    }
                })
                this.bs.push(bb);
            },
 
            // 获取Host
            getHost: function () {
                return USE_PROXY ? "easy-data/" : JD_API + "easy-data/";
            },
 
            // 异步Ajax
            ajax: function (url, type, data, dataType, contentType, fn) {
                $.ajax({
                    url: this.getHost() + url,
                    type: type,
                    data: data,
                    dataType: dataType || "json", // html、json、jsonp、script、text
                    contentType: contentType || "application/json", //"application/x-www-form-urlencoded"
                    success: function (data) {
                        fn(data);
                    },
                    error: function (e) {
                        console.error(e);
                        fn();
                    }
                });
            }
        };
 
        $(function () {
            UE.init();
            UE.getCY();
        });
    </script>
</head>
 
<body>
  <div id="map"></div>
 
  <div id="ctrl">
    产业:<select id="cySelect" onchange="UE.cyChange(this);"><option selected="selected" value="">请选择</option></select>
    产业点:<select id="cydSelect" onchange="UE.cydChange(this);"><option selected="selected" value="">请选择</option></select>
  </div>
</body>
 
</html>