-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
675 lines (573 loc) · 20.8 KB
/
index.html
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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
<!DOCTYPE html>
<html lang="en">
<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>
<!--Echarts-->
<script type="text/javascript" src="https://fastly.jsdelivr.net/npm/[email protected]/dist/echarts.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/echarts/dist/echarts.js"></script>
<!-- <script src="libs/node_modules/ol-echarts/dist/ol-echarts.js"></script> -->
<!--FontAwesome开源库-->
<link type="text/css" rel="stylesheet" href="libs/font-awesome-4.7.0/css/font-awesome.min.css">
<!-- 开源库jQuery -->
<script src="libs/jquery-1.11.2.min.js"></script>
<!-- 百度API -->
<script type="text/javascript" src="https://api.map.baidu.com/api?v=3.0&ak=kB5yeVizxgKa82lXGOdvTiEpyzPeEzSx"></script>
<script type="text/javascript"
src="https://fastly.jsdelivr.net/npm/[email protected]/dist/extension/bmap.min.js"></script>
<script type="text/javascript"
src="https://api.map.baidu.com/api?v=1.0&&type=webgl&ak=kB5yeVizxgKa82lXGOdvTiEpyzPeEzSx"></script>
</head>
<style>
#header {
width: 100%;
height: 50px;
z-index: 0;
position: absolute;
background-color: rgba(0, 0, 0, 0.2);
vertical-align: middle;
}
#header #title {
width: 550px;
height: 100%;
margin: 0 auto;
/*设置logo*/
background-image: url('./images/department_logo/blue_cn_dp.png'), url('./images/校徽+中英文火炬/组合1:校徽+中英文校名-左右/LOGO.png');
background-size: auto 100%, auto 260px;
background-position: 100% 50%, 0% 50%;
background-repeat: no-repeat;
}
* {
padding: 0;
margin: 0;
list-style: none;
text-decoration: none;
}
.sidebar {
position: fixed;
left: -400px;
width: 400px;
height: 100%;
background: rgba(0, 63, 67, 1);
transition: all .5s ease;
z-index: 1;
}
.sidebar .top {
font-size: 22px;
color: #fff;
text-align: center;
height: 60px;
line-height: 51px;
background-color: rgb(14, 44, 70);
user-select: none;
}
.sidebar ul a {
display: block;
height: 100%;
width: 100%;
text-align: center;
line-height: 45px;
font-size: 18px;
color: #fff;
box-sizing: border-box;
border-top: 1px solid rgba(255, 255, 255, .1);
border-bottom: 1px solid rgb(17, 73, 118);
transition: .4s;
}
ul li:hover a {
padding-left: 30px;
color: #5587f4;
border-left: 5px solid #5587f4;
transition: all 0.5s;
}
.sidebar ul a i {
margin-right: 16px;
}
#check {
display: none;
margin-top: 20px;
}
label #btn,
label #cancel {
position: fixed;
cursor: pointer;
background-color: #0c587e;
border-radius: 3px;
}
label #btn {
left: 5px;
top: 7px;
font-size: 25px;
color: #fff;
padding: 6px 10px;
transition: all .5s;
z-index: 1;
}
label #cancel {
z-index: 2;
left: -145px;
top: 10px;
font-size: 25px;
color: rgb(188, 190, 223);
padding: 4px 9px;
transition: all .5s ease;
}
#check:checked~.sidebar {
left: 0;
}
#check:checked~label #btn {
left: 10px;
opacity: 0;
pointer-events: none;
}
#check:checked~label #cancel {
left: 350px;
z-index: 2;
}
.content {
height: 100vh;
transition: all .5s;
display: flex;
justify-content: space-around;
z-index: 0;
}
.map {
height: 100%;
width: 100%;
margin-top: 55px;
margin-left: 5px;
margin-right: 5px;
}
#check:checked~.content {
margin-left: 400px;
}
#datadisplay {
background-color: rgba(106, 113, 108, 0.2);
margin-right: 5px;
width: 25%;
height: 100%;
margin-top: 55px
}
/*科考信息窗口的可滑动css*/
#img-content {
width: 100%;
overflow-x: auto;
}
.img-list {
display: flex;
width: 2400px;
}
.img-list .img-list-item {
width: 100%;
height: 100%;
}
.img-list .img-list-item+.img-list-item {
margin-left: 20px;
}
.img-list .img-list-item img {
width: 100%;
height: 100%;
}
</style>
<body>
<!--网页标题部分-->
<div id="header">
<div id="title"></div>
</div>
<!--设置开启与关闭时的卡片开关-->
<input type="checkbox" id="check">
<label for="check">
<i class="fa fa-bars" id="btn"> More</i>
<i class="fa fa-times" id="cancel"></i>
</label>
<!--打开时的卡片图层管理区-->
<div class="sidebar">
<div class="top">Hi~</div>
<!-- <li><a href="#">
<strong style="font-size: larger;">动态地震(暂)</strong>
<input type="checkbox" id="start_Anime">
</a>
</li> -->
<ul>
<li style="text-align:center">
<a href="http://ess.sustech.edu.cn/New-detail-id-655.html" target="_blank" style="display:inline "><i
class="fa fa-plane" aria-hidden="true"></i>青海科考</a> 
<a href="https://www.bilibili.com/video/BV1Yg411k7gG?spm_id_from=333.999.0.0&vd_source=47b2afbe45bd57551a7d1e2080630131&t=65.8"
target="_blank" style="display:inline"><i class="fa fa-file-video-o" aria-hidden="true"></i></a>
</li>
</ul>
<ul>
<li style="text-align:center">
<a href="https://faculty.sustech.edu.cn/chenkj/" target="_blank" style="display:inline "><i
class="fa fa-address-book"></i>关于我们</a> 
<a href="./videos/video_0.mp4" target="_blank" style="display:inline"><i class="fa fa-file-video-o"
aria-hidden="true"></i></a>
</li>
</ul>
<ul>
<li style="text-align:center">
<li>
<a href="#">
<!-- <i class="fa fa-address-book"></i> -->
<strong style="font-size: larger;">成果</strong>
<input type="checkbox" id="setmarker" checked>
<!-- <i class="fa fa-address-book"></i> --> 
<strong style="font-size: larger;">地震</strong>
<input type="checkbox" id="setearthquake" checked>
</a>
</li>
</li>
</ul>
</div>
<!--主地图展示区-->
<div class="content" id="content">
<div class="map" id="map"> </div>
<!-- http://ess.sustech.edu.cn/New-detail-id-655.html -->
</body>
<script>
//为动态地震设计的刷新函数
function mounted(item, option) {
this.interval = setInterval(() => {
window.location.reload();
item.setOption(option)
console.log('option 已重新')
//selectAdd()
}, 60000);
document.onclick = (event) => {
clearInterval(this.interval);
this.interval = setInterval(() => {
window.location.reload();
item.setOption(option)
console.log('option 已重新1')
//selectAdd()
}, 60000);
};
}
//这里小放一个时间戳转换工具
function add0(m) { return m < 10 ? '0' + m : m }
function format(shijianchuo) {
//shijianchuo是整数,否则要parseInt转换
var time = new Date(shijianchuo);
var y = time.getFullYear();
var m = time.getMonth() + 1;
var d = time.getDate();
var h = time.getHours();
var mm = time.getMinutes();
var s = time.getSeconds();
return y + '-' + add0(m) + '-' + add0(d) + ' ' + add0(h) + ':' + add0(mm) + ':' + add0(s);
}
</script>
<!--以Echarts方式加载动态地震-->
<script>
/* //checjbox函数,搁置ing
var start_anime = document.getElementById('start_Anime')
start_anime.addEventListener('click', (event) => {
if (event.target.checked) {
mychart_earthquake.setOption(option_anime, true)
}
else {
var option_blank = {
title: {},
tooltip: {
trigger: 'item'
},
bmap: {
center: [104.114129, 37.550339],
zoom: 1,
roam: true,
mapStyle: {}
}
}
mychart_earthquake.setOption(option_blank, true)
}
}
) */
//2022.9.3记,终于解决了困扰已久的问题:如何让程序在url数据加载完毕后再执行” 找到了解决方案,这其实就是一个异步问题,这里使用XMLHttpRequest的相关功能,这个方法的其他用途很值得开发
//修改代码结构,放弃之前以addEventListener人为异步的方式
/*当open的第三个参数为true时,只有当url中的资源加载完毕时,onload函数才会执行*/
var mapdata = new XMLHttpRequest();
mapdata.open("GET", "https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_month.geojson", true);
mapdata.send();
//使用onload启动Echarts绘制
mapdata.onload = function () {
var datatest = mapdata.responseText//geojson数据被存在responseText之中,为string格式
var testjson = $.parseJSON(datatest)//将string格式数据保存为JSON格式,以便数据的读取与使用
console.log(testjson)
//JSON格式数据统一以json['']一层层读取
var feature = testjson['features']
var reshape = []
var reshape_anime = []//两个空数集,分别用于存储series里的两部分数据
feature.forEach(function (item) {
//遍历,然后根据JSON取值方法对其进行取值
var geo = item['geometry']
var coor = geo['coordinates'];
var property = item['properties']
var xy = [(coor[0]).toFixed(2), (coor[1]).toFixed(2), (coor[2]).toFixed(2)]
var xy_num = [parseFloat(xy[0]), parseFloat(xy[1]), parseFloat(xy[2])]
//console.log(xy_num)
var date_now = Date.now()
//进行震级区分与发震时间的区分,并分别使用push函数给[]中赋值
if (property['mag'] >= 6 && (date_now - property['time']) <= (7 * 24 * 60 * 60 * 1000)) {
reshape_anime.push({
name: property['place'].concat('\n', format(property['time'])),
value: [xy_num[0], xy_num[1], xy_num[2], property['mag']]
})
}
else {
reshape.push({
name: property['place'].concat('\n', format(property['time'])),
value: [xy_num[0], xy_num[1], xy_num[2], property['mag']]
})
}
})
//Echarts配置项
var option_anime = {
title: {
text: '陈克杰课题组',
subtext: 'Earthquake data from USGS',
sublink: 'https://earthquake.usgs.gov/earthquakes/feed/',
left: 'center'
},
tooltip: {
trigger: 'item'
},
//由option创建bmap实例对象
bmap: {
center: [104.114129, 37.550339],
zoom: 1,
roam: true,
mapStyle: {}
},
series: [
{
name: '近一月地震',
type: 'scatter',
coordinateSystem: 'bmap',
data: reshape,
symbolSize: function (val) {
var bj = 0
if (val[3] < 5.0) { bj = 15 - (5 - val[3]) * 3 }
else { bj = 15 + (val[3] - 5) * 6 }
return bj;
},
encode: { value: 3 },
label: {
formatter: '{b}',
position: 'right',
show: false
},
itemStyle: {
color: 'rgba(222,22,22,0.5)',
},
emphasis: {
label: {
show: false
}
}
},
{
name: '近一周五级以上地震',
type: 'effectScatter',
coordinateSystem: 'bmap',
data: reshape_anime,
symbolSize: function (val) {
return (20 + (val[3] - 5) * (val[3] - 5) * 12);
},
encode: {
value: 3
},
showEffectOn: 'render',
rippleEffect: {
brushType: 'stroke',
},
hoverAnimation: true,
label: {
normal: {
formatter: '{b}',
position: 'top',
show: true//显示标签,默认使用name中的数据
}
},
itemStyle: {
color: 'purple',
shadowBlur: 10,
shadowColor: '#333'
},
zlevel: -100
}
]
}
var option_empty = {
title: {
text: '陈克杰课题组',
subtext: 'Earthquake data from USGS',
sublink: 'https://earthquake.usgs.gov/earthquakes/feed/',
left: 'center'
},
tooltip: {
trigger: 'item'
},
//由option创建bmap实例对象
bmap: {
center: [104.114129, 37.550339],
zoom: 1,
roam: true,
mapStyle: {}
},
series: []
}
var mychart_earthquake = echarts.init(document.getElementById('map'));//初始化
mychart_earthquake.setOption(option_anime, true)//绘制
/*尝试获取echarts中的示例对象并作出修改以及添加标记等*/
var mybmap = mychart_earthquake.getModel().getComponent('bmap').getBMap(); //获取map
mybmap.setMapStyle({ style: 'normal' });//设置地图style
//其他控件等
mybmap.addControl(new BMap.MapTypeControl());
mybmap.addControl(new BMap.ScaleControl());
mybmap.enableContinuousZoom();
var c = new BMap.OverviewMapControl();
mybmap.addControl(c);
//用于手动加入课题组成果数据集,因为数据量较少可以直接代码内定义
var data_info = [['DOI: 10.13203/j.whugis20220140', 98.251, 34.598, './images/chs_1.png', './images/label.png', 'http://ch.whu.edu.cn/cn/article/doi/10.13203/j.whugis20220140?viewType=SUP', "show"],
['DOI: 10.3390/rs14092018', -157.888, 55.364, './images/ljf_1.png', './images/label.png', 'https://doi.org/10.3390/rs14092018', "show"],
['DOI: 10.1016/j.tecto.2022.229542', 98.451, 35.0, './images/lmz_1.png', './images/label.png', 'https://doi.org/10.1016/j.tecto.2022.229542', "show"],
['DOI: 10.1007/s10346-021-01782-7', 109.305045, 30.369805, './images/xch_1.png', './images/landslide.png', 'https://doi.org/10.1007/s10346-021-01782-7', "show"],
['DOI: 10.3390/s19112559', 114.25, 22.25, './images/wgg_1.png', './images/label.png', 'https://doi.org/10.3390/s19112559', "show"],
['DOI: 10.11947/j.AGCS.2021.20200163', 108.93, 34.27, './images/zh_1.png', './images/label.png', 'http://xb.chinasmp.com/CN/Y2021/V50/I3/356', "show"]]
//遍历为每一个添加标记和图标与信息窗口
function drawmarker(bmap) {
for (var i = 0; i < data_info.length; i++) {
//为每一个Marker设定icon,这样得到的size和anchor是一致地
var myIcon = new BMap.Icon(data_info[i][4], new BMap.Size(25, 25), { anchor: new BMap.Size(10, 10) });
//Marker的定义,这里只用上了point类型,后续有需要可以研究其他的使用
var marker = new BMap.Marker(new BMap.Point(data_info[i][1], data_info[i][2]), { icon: myIcon })
//为信息窗口设定内容
var show_content =
"<h4 style='margin:0 0 5px 0;padding:0.2em 0'>" + "<a href=" + data_info[i][5] + " target='_blank'>" + data_info[i][0] + "</a>" + "</h4>" +
"<img style='float:right;margin:4px' id='imgDemo' src='" + data_info[i][3] + "' width='450' height='615' ' />"
bmap.addOverlay(marker);
addClickHandler(show_content, marker);
}
//设置点击mark打开信息窗口
function addClickHandler(cont, mark) {
mark.addEventListener("click", function (e) {
openInfo(cont, e)
})
}
//设置信息窗口对象
function openInfo(cont, e) {
var p = e.target;
var point = new BMap.Point(p.getPosition().lng, p.getPosition().lat);
var infoWindow = new BMap.InfoWindow(cont, { height: 0, width: 0 }); // 创建信息窗口对象
bmap.openInfoWindow(infoWindow, point); //开启信息窗口
}
//科考
var icon_qinghai = new BMap.Icon('./images/qinghai/qinghai_label.png', new BMap.Size(70, 100), { anchor: new BMap.Size(10, 10) })
var qinghai_marker = new BMap.Marker(new BMap.Point(99.895, 36.693), { icon: icon_qinghai })
var qinghai_show = `
<h3 style='text-align:center;margin:4px'>青海科考</h3>
<div id="img-content">
<ul class="img-list">
<li class="img-list-item">
<img src="./images/qinghai/qinghai_01.jpg" alt="">
</li>
<li class="img-list-item">
<img src="./images/qinghai/qinghai_02.jpg" alt="">
</li>
<li class="img-list-item">
<img src="./images/qinghai/qinghai_03.jpg" alt="">
</li>
<li class="img-list-item">
<img src="./images/qinghai/qinghai_04.jpg" alt="">
</li>
<li class="img-list-item">
<img src="./images/qinghai/qinghai_05.jpg" alt="">
</li>
<li class="img-list-item">
<video src="https://www.bilibili.com/video/BV1Yg411k7gG?spm_id_from=333.999.0.0&vd_source=47b2afbe45bd57551a7d1e2080630131&t=65.8" controls="controls" poster="./videos/poster_1.png" width="100%" height="250px" alt=""></video>
</li>
</ul>
</div>
`
bmap.addOverlay(qinghai_marker)
qinghai_marker.addEventListener("click", function (e) {
var p = e.target;
var point = new BMap.Point(p.getPosition().lng, p.getPosition().lat);
var infoWindow = new BMap.InfoWindow(qinghai_show, { height: 300, width: 400 }); // 创建信息窗口对象
bmap.openInfoWindow(infoWindow, point); //开启信息窗口
})
}
drawmarker(mybmap)
//页面大小改变,resize
window.addEventListener('resize', mychart_earthquake.resize);
//按键resize
window.addEventListener('keydown', mychart_earthquake.resize);
//关闭卡片,resize一次,可以解决因为flex改变了div的长度使scatter出现切割现象
var resize = document.getElementById('cancel')
resize.addEventListener('click', (event) => {
setTimeout(function () { mychart_earthquake.resize() }, 500);
})
//mounted函数内置了setinternal按间隔刷新option
mounted(mychart_earthquake, option_anime)
//测试定位 发现了一个被忽视的小问题,原来我一直用的是3.0的百度api,使用的是BMap下的功能
//后面开发可能更多的要接触1.0的WebGL下的若干功能
//比如此例也可以用BMap的,但是BMapGL似乎更加简便
var location = new BMapGL.Geolocation();
location.getCurrentPosition(function (r) {
if (this.getStatus() == BMAP_STATUS_SUCCESS) {
var mk = new BMap.Marker(new BMap.Point(r.point.lng, r.point.lat));
mybmap.addOverlay(mk);
//alert('您的位置:' + r.point.lng + ',' + r.point.lat);
}
else {
//alert('failed' + this.getStatus());
}
});
/*实现图层自由切换*/
//根据标签移除marker的函数
function remove_mark(id) {
var all = mybmap.getOverlays();
for (let i = 0; i < all.length - 1; i++) {
if (all[i][6] == id) {
mybmap.removeOverlay(all[i])
}
}
}
//链接用于切换标记的复选框,并设定响应函数
var setmark = document.getElementById('setmarker')
setmark.addEventListener('click', (event) => {
if (event.target.checked) {
//由于切换地震显示会刷新option,故需重新获取最新的bmap对象并予以赋值,后面同理
mybmap = mychart_earthquake.getModel().getComponent('bmap').getBMap(); //获取map
drawmarker(mybmap)
}
else {
mybmap = mychart_earthquake.getModel().getComponent('bmap').getBMap(); //获取map
remove_mark()
}
})
//链接用于切换地震的复选框,并设定响应函数
var setpoint = document.getElementById('setearthquake')
setpoint.addEventListener('click', (event) => {
if (event.target.checked) {
mychart_earthquake.setOption(option_anime, true)//绘制
mybmap = mychart_earthquake.getModel().getComponent('bmap').getBMap(); //获取map
//为不影响标记的状态,需要进行检查并恢复标记
if (setmark.checked == true) { drawmarker(mybmap) }
else { }
}
else {
mychart_earthquake.setOption(option_empty, true)//绘制
mybmap = mychart_earthquake.getModel().getComponent('bmap').getBMap(); //获取map
if (setmark.checked == true) { drawmarker(mybmap) }
else { }
}
})
}
</script>
<script>
</script>
</html>