-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
1470 lines (1196 loc) · 40.9 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
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!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>Document</title>
<script src="https://cdn.staticfile.org/echarts/4.3.0/echarts.min.js"></script>
<link type="text/css" rel="stylesheet" href="libs/font-awesome-4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="libs/ol.css">
<script src="libs/ol.js"></script>
<!-- 开源库jQuery -->
<script src="libs/jquery-1.11.2.min.js"></script>
<!-- fileSaver开源库,用于保存数据 -->
<script src="libs/FileSaver.js"></script>
<!-- 百度API实现搜索定位 -->
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=kB5yeVizxgKa82lXGOdvTiEpyzPeEzSx"></script>
</head>
<style>
#header {
width: 100%;
height: 50px;
z-index: 0;
position: absolute;
background-color: #aeb8c1;
background-image: url('images/title.png');
background-position: center;
background-repeat: no-repeat;
vertical-align: middle;
}
#header #title {
font-size: 28px;
font-family: "宋体";
color: rgb(0, 0, 0);
text-align: center;
height: 60px;
line-height: 51px;
}
* {
padding: 0;
margin: 0;
list-style: none;
text-decoration: none;
}
.sidebar {
position: fixed;
left: -400px;
width: 400px;
height: 100%;
background: #084561;
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: 75%;
margin-top: 55px;
margin-left: 5px;
margin-right: 5px;
}
#check:checked~.content {
margin-left: 400px;
}
#datadisplay {
background-color: rgba(42, 165, 85, 0.2);
margin-right: 5px;
width: 25%;
height: 100%;
margin-top: 55px
}
</style>
<body>
<div id="header">
<h1 id="title"> <strong>地壳形变监测成果在线管理系统</strong></h1>
</div>
<input type="checkbox" id="check">
<label for="check">
<i class="fa fa-bars" id="btn"> 图层管理</i>
<i class="fa fa-times" id="cancel"></i>
</label>
<div class="sidebar">
<div class="top">Hi~</div>
<ul>
<li>
<li>
<a href="#">
<!-- <i class="fa fa-address-book"></i> -->
<strong style="font-size: larger;">实时地震</strong>
<input type="checkbox" id="setV" checked>
</a>
</li>
<div id="earthquake_C_one">
<a>近一小时 <input type="checkbox" id="hour">  
近一天 <input type="checkbox" id="day"> 
近一周 <input type="checkbox" id='week'> 
近一个月 <input type="checkbox" id='month'> 
</a>
</div>
</li>
<li><a href="#">
<!-- <i class="fa fa-telegram"></i> -->
<strong style="font-size: larger;">中国区域地震(近五年)</strong>
<input type="checkbox" id="setV_C" checked>
</a>
</li>
<div id="earthquake_C_two">
<a>
震级: 
2.5-4.5 <input type="checkbox" id="25">  
4.5-6.5 <input type="checkbox" id="45"> 
6.5+<input type="checkbox" id='65'> 
</a>
</div>
<li><a href="#">
<!-- <i class="fa fa-address-book"></i> -->
<strong style="font-size: larger;">InSAR形变图(选中指定地震)</strong>
<input type="checkbox" id="set_InSAR" checked>
</a>
</li>
<div id="InSAR">
<a>
方位一 <input type="checkbox" id="insar_1">  
方位二 <input type="checkbox" id="insar_2"> 
方位三 <input type="checkbox" id='insar_3'> 
方位四 <input type="checkbox" id='insar_4'> 
</a>
</div>
<li><a href="#">
<!-- <i class="fa fa-telegram"></i> -->
<strong style="font-size: larger;">中国区域形变场</strong>
<input type="checkbox" id="set_Velocity" checked>
</a>
</li>
<div id="Velocity">
<a>
参考系:
ITRF2008<input type="checkbox" id="velocity_1">  
欧亚大陆<input type="checkbox" id="velocity_2">  
</a>
</div>
<li><a href="#"><i class="fa fa-address-book"></i>关于我们</a></li>
</ul>
</div>
<div class="content">
<div class="map" id="map"> </div>
<!-- 弹窗要素 -->
<div id="popup" class="ol-popup" style="background-color: rgba(255,255,255,0.7);">
<div style="width: 100%;">
<strong style="text-align: left;margin-left: 10px;width: 10%;">地震信息</strong>
<a href="#" id="popup-closer" class="ol-popup-closer" style="float: right;">x</a>
</div>
<div id="popup-content" style="display: inline-block;text-align:left; margin: 10px;"></div>
</div>
<!-- 右侧展示功能区 -->
<div id="datadisplay">
<p style="margin: 10px; text-align: center;"><strong>中国区域地震筛选与分析</strong></p>
<hr>
<p style="margin: 5px;">时间筛选:</p>
<p style="margin: 10px;">
起:<input type="number" style="width:50px" value="2017" id="start_y">年<input type="number" style="width:30px"
value="10" id="start_m">月<input type="number" style="width:30px" value="10" id="start_d"> 日
</p>
<p style="margin: 10px;">
止:<input type="number" style="width:50px" value="2022" id="end_y">年<input type="number" style="width:30px"
value="10" id="end_m">月<input type="number" style="width:30px" value="10" id="end_d"> 日
</p>
<p style="margin: 5px;">震级筛选:</p>
<p style="margin:8px;">
Mag:<input type="number" style="width:35px" value="2.5" id="start_Mag" step="0.1"> 至 <input
type="number" style="width:35px" value="6.5" id="end_Mag" step="0.1">
</p>
<hr>
<p style="margin:5px;">
城市名称:<input type="text" style="width:80px ;height:20px" id="cityname">
<input type="button" value="搜索" onclick="myLocation()"
style="margin-top: 5px; height: 30px; width: 35px;font-size: 16px; font-family: '宋体'; background-color: #e9e4a0; border: rgba(70, 68, 68, 0.9);" />
<input type="button" value="定位" id="spin"
style="margin-top: 5px; height: 30px; width: 35px;font-size: 16px; font-family: '宋体'; background-color: #e9e4a0; border: rgba(70, 68, 68, 0.9);" />
</p>
<HR>
<p>
<input type="button" value="筛选并显示" onclick="selectAdd()"
style="margin-top: 5px;margin-left: 5px; height: 30px; width: 88px;font-size: 16px; font-family: '宋体'; background-color: #a0d2e9; border: rgba(70, 68, 68, 0.9);" />
<input type="button" value="绘制统计图" onclick="draw()"
style="margin-top: 5px; height: 30px; width: 88px;font-size: 16px; font-family: '宋体'; background-color: #a0d2e9; border: rgba(70, 68, 68, 0.9);" />
<input type="button" value="绘制热力图" onclick="heatmap()"
style="margin-top: 5px; height: 30px; width: 88px;font-size: 16px; font-family: '宋体'; background-color: #a0d2e9; border: rgba(70, 68, 68, 0.9);" />
<input type="button" value="移除" onclick="selectOff()"
style="margin-top: 5px; margin-bottom: 5px; height: 30px; width: 50px;font-size: 16px; font-family: '宋体'; background-color: #a0d2e9; border: rgba(70, 68, 68, 0.9);" />
<input type="button" value="保存" onclick="selectSave()"
style="margin-top: 5px; height: 30px; width: 50px;font-size: 16px; font-family: '宋体'; background-color: #a0d2e9; border: rgba(70, 68, 68, 0.9);" />
</p>
<div style="margin-left: 5px;">
<label class="lb">热点半径:</label><input style="width: 70px;" type="range" id="radius" min="1" max="50" step="1"
value="10" />
<label class="lb">模糊尺寸:</label><input style="width: 70px;" type="range" id="blur" min="1" max="50" step="1"
value="15" />
</div>
<div id="Mag_Echarts_1" style="margin-left:5px; width: 100%; height: 250px; background-color: beige;"></div>
<div id="Mag_Echarts_2" style="margin-left:5px; width: 100%; height: 250px; background-color: beige;"></div>
<hr>
<div id="data_detail"
style="display: inline-block;text-align:left; margin: 10px; height:max-content; width: 100%;">
</div>
</div>
</div>
</body>
<script>
//用于筛选的图层
var select_layer = new ol.layer.Vector({
source: new ol.source.Vector({
format: new ol.format.GeoJSON({ extractStyles: false }),
})
})
var chinaextent = [7938658, 1055130, 16125429, 7345809]
var map = new ol.Map({
target: 'map',
layers: [new ol.layer.Tile({ source: new ol.source.OSM() }), select_layer],
view: new ol.View({
center: ol.extent.getCenter(chinaextent),
projection: 'EPSG:3857',
zoom: 4.5
}),
controls: ol.control.defaults().extend([
new ol.control.ZoomSlider(),
new ol.control.ZoomToExtent({
extent:
chinaextent
//定位
}),
new ol.control.MousePosition(),
new ol.control.FullScreen(),
new ol.control.OverviewMap({ // 实例化一个OverviewMap类的对象,并加入到地图中
collapsed: false,
//教程有误,需要加入新的layers和view,否则鹰眼框与主视图使用统一图层会显示空白
layers: [new ol.layer.Tile({ source: new ol.source.OSM() })],
view: new ol.View({
center: [0, 0],
projection: 'EPSG:3857',
zoom: 4
}),
}),
new ol.control.ScaleLine({
units: "metric",//设置比例尺单位,degrees、imperial、us、nautical、metric(度量单位)
bar: false
}),
])
});
</script>
<!-- 实时地震切换脚本区 -->
<script>
var vector_hour = new ol.layer.Vector({
source: new ol.source.Vector({
url: 'https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_hour.geojson',
format: new ol.format.GeoJSON({ extractStyles: false }),
}),
style: new ol.style.Style({
image: new ol.style.Circle({
radius: 5,
fill: new ol.style.Fill({
color: 'rgba(255,15,15,0.4)'
})
})
})
})
var vector_day = new ol.layer.Vector({
source: new ol.source.Vector({
url: 'https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_day.geojson',
format: new ol.format.GeoJSON({ extractStyles: false }),
}),
style: new ol.style.Style({
image: new ol.style.Circle({
radius: 5,
fill: new ol.style.Fill({
color: 'rgba(255,15,15,0.4)'
})
})
})
})
var vector_week = new ol.layer.Vector({
source: new ol.source.Vector({
url: 'https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_week.geojson',
format: new ol.format.GeoJSON({ extractStyles: false }),
}),
style: new ol.style.Style({
image: new ol.style.Circle({
radius: 5,
fill: new ol.style.Fill({
color: 'rgba(255,15,15,0.4)'
})
})
})
})
var vector_month = new ol.layer.Vector({
//创建地震点要素矢量图层vector
source: new ol.source.Vector({
url: 'https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_month.geojson',
format: new ol.format.GeoJSON({ extractStyles: false }),
}),
//style要放在source外面和它并列啊你这个笨蛋
style: new ol.style.Style({
//因为把image打成Image又浪费了我半个小时
image: new ol.style.Circle({
radius: 5,
fill: new ol.style.Fill({
color: 'rgba(255,15,15,0.4)'
})
})
})
})
/* function E_update(){
var setv=document.getElementById('setV')
if(setv.checked==ture){
setv.checked=false
}
else{
setv.checked=true
}
} */
var setv = document.getElementById('setV')
setv.addEventListener('click', (event) => {
if (event.target.checked) {
vector_hour.setVisible(true)
vector_day.setVisible(true)
vector_week.setVisible(true)
vector_month.setVisible(true)
console.log('实时地震设为可见')
}
else {
vector_hour.setVisible(false)
vector_day.setVisible(false)
vector_week.setVisible(false)
vector_month.setVisible(false)
console.log('实时地震已隐藏')
}
})
var checkhour = document.getElementById('hour')
var checkday = document.getElementById('day')
var checkweek = document.getElementById('week')
var checkmonth = document.getElementById('month')
let controls = document.getElementById('earthquake_C_one')
controls.addEventListener('click', (event) => {
if (event.target.checked) {
//newlayer.setVisible(false)
switch (event.target.id) {
case "hour":
checkday.checked = false
checkweek.checked = false
checkmonth.checked = false
map.removeLayer(vector_day)
map.removeLayer(vector_week)
map.removeLayer(vector_month)
map.addLayer(vector_hour)
break;
case "day":
checkhour.checked = false
checkweek.checked = false
checkmonth.checked = false
map.removeLayer(vector_hour)
map.removeLayer(vector_week)
map.removeLayer(vector_month)
map.addLayer(vector_day)
break;
case "week":
checkday.checked = false
checkhour.checked = false
checkmonth.checked = false
map.removeLayer(vector_day)
map.removeLayer(vector_hour)
map.removeLayer(vector_month)
map.addLayer(vector_week)
break;
case "month":
checkday.checked = false
checkweek.checked = false
checkhour.checked = false
map.removeLayer(vector_day)
map.removeLayer(vector_week)
map.removeLayer(vector_hour)
map.addLayer(vector_month)
break;
default:
break;
}
Myaddinteraction()
}
else {
switch (event.target.id) {
case "hour":
map.removeLayer(vector_hour)
break;
case "day":
map.removeLayer(vector_day)
break;
case "week":
map.removeLayer(vector_week)
break;
case "month":
map.removeLayer(vector_month)
break;
default:
break;
}
}
})
</script>
<!-- 中国区域 -->
<script>
var vector_25 = new ol.layer.Vector({
source: new ol.source.Vector({
url: '/data/geojson/earthquake/2.5-4.4china2017-2022.5.1.json',
format: new ol.format.GeoJSON({ extractStyles: false }),
}),
style: new ol.style.Style({
image: new ol.style.Circle({
radius: 5,
fill: new ol.style.Fill({
color: 'rgba(0, 255,0 , 0.2)'
})
})
})
})
var vector_45 = new ol.layer.Vector({
source: new ol.source.Vector({
url: '/data/geojson/earthquake/4.5-6.4china2017-2022.5.1.json',
format: new ol.format.GeoJSON({ extractStyles: false }),
}),
style: new ol.style.Style({
image: new ol.style.Circle({
radius: 5,
fill: new ol.style.Fill({
color: 'rgba(0, 0,255 , 0.2)'
})
})
})
})
var vector_65 = new ol.layer.Vector({
source: new ol.source.Vector({
url: '/data/geojson/earthquake/6.5+china2017-2022.5.1.json',
format: new ol.format.GeoJSON({ extractStyles: false }),
}),
style: new ol.style.Style({
image: new ol.style.Circle({
radius: 5,
fill: new ol.style.Fill({
color: 'rgba(255, 0,0 , 0.2)'
})
})
})
})
var setv = document.getElementById('setV_C')
setv.addEventListener('click', (event) => {
if (event.target.checked) {
vector_25.setVisible(true)
vector_45.setVisible(true)
vector_65.setVisible(true)
console.log('中国地震设为可见')
}
else {
vector_25.setVisible(false)
vector_45.setVisible(false)
vector_65.setVisible(false)
console.log('中国地震已隐藏')
}
})
var check25 = document.getElementById('25')
var check45 = document.getElementById('45')
var check65 = document.getElementById('65')
let controls_C = document.getElementById('earthquake_C_two')
controls_C.addEventListener('click', (event) => {
if (event.target.checked) {
//newlayer.setVisible(false)
switch (event.target.id) {
case "25":
map.addLayer(vector_25)
break;
case "45":
map.addLayer(vector_45)
break;
case "65":
map.addLayer(vector_65)
break;
default:
break;
}
Myaddinteraction()
}
else {
switch (event.target.id) {
case "25":
map.removeLayer(vector_25)
break;
case "45":
map.removeLayer(vector_45)
break;
case "65":
map.removeLayer(vector_65)
break;
default:
break;
}
}
})
</script>
<!-- InSAR -->
<script>
var url_1, url_2, url_3, url_4
var insar1 = new ol.layer.Tile({
})
var insar2 = new ol.layer.Tile({
})
var insar3 = new ol.layer.Tile({
})
var insar4 = new ol.layer.Tile({
})
var set_InSAR = document.getElementById('set_InSAR')
set_InSAR.addEventListener('click', (event) => {
if (event.target.checked) {
insar1.setVisible(true)
insar2.setVisible(true)
insar3.setVisible(true)
insar4.setVisible(true)
console.log('InSAR设为可见')
}
else {
insar1.setVisible(false)
insar2.setVisible(false)
insar3.setVisible(false)
insar4.setVisible(false)
console.log('InSAR已隐藏')
}
})
var check1 = document.getElementById('insar_1')
var check2 = document.getElementById('insar_2')
var check3 = document.getElementById('insar_3')
var check4 = document.getElementById('insar_4')
let controls_InSAR = document.getElementById('InSAR')
controls_InSAR.addEventListener('click', (event) => {
if (event.target.checked) {
//newlayer.setVisible(false)
switch (event.target.id) {
case "insar_1":
insar1.setSource(new ol.source.TileWMS({
url: url_1
}))
map.addLayer(insar1)
break;
case "inar_2":
insar2.setSource(new ol.source.TileWMS({
url: url_2
}))
map.addLayer(insar2)
break;
case "insar_3":
insar3.setSource(new ol.source.TileWMS({
url: url_3
}))
map.addLayer(insar3)
break;
case "insar_4":
map.addLayer(insar4)
insar4.setSource(new ol.source.TileWMS({
url: url_4
}))
break;
default:
break;
}
Myaddinteraction()
}
else {
switch (event.target.id) {
case "insar_1":
map.removeLayer(insar1)
break;
case "insar_2":
map.removeLayer(insar2)
break;
case "insar_3":
map.removeLayer(insar3)
break;
case "insar_4":
map.removeLayer(insar4)
break;
default:
break;
}
}
})
</script>
<!-- 形变场 -->
<script>
var styleFunction_1 = function (feature) {
var geometry = feature.getGeometry();
var property = feature.getProperties();
let dx = property['Ve_I']
let dy = property['Vn_I']
var rotation = Math.atan2(dy, dx);
var start = [geometry.getCoordinates()[0], geometry.getCoordinates()[1]]
var new_x = geometry.getCoordinates()[0] + dx * 3000 //这里的指数得根据屏幕坐标进行调节
var new_y = geometry.getCoordinates()[1] + dy * 3000
var end = [new_x, new_y]
var styles = [
new ol.style.Style({
stroke: new ol.style.Stroke({
color: 'blue',
width: 1.0,
}),
geometry: new ol.geom.LineString([start, end]),
//projection:'EPSG:4326',
})
];
styles.push(new ol.style.Style({
geometry: new ol.geom.Point([new_x, new_y]),
//projection:'EPSG:4326',
image: new ol.style.Icon({
src: 'images/myarrow_blue.png',
anchor: [0.75, 0.5],
rotateWithView: true,
rotation: -rotation,
}),
}))
return styles
}
var styleFunction_2 = function (feature) {
var geometry = feature.getGeometry();
var property = feature.getProperties();
let dx = property['Ve_E']
let dy = property['Vn_E']
var rotation = Math.atan2(dy, dx);
var start = [geometry.getCoordinates()[0], geometry.getCoordinates()[1]]
var new_x = geometry.getCoordinates()[0] + dx * 14000 //这里的指数得根据屏幕坐标进行调节
var new_y = geometry.getCoordinates()[1] + dy * 14000
var end = [new_x, new_y]
var styles = [
new ol.style.Style({
stroke: new ol.style.Stroke({
color: 'red',
width: 1.0,
}),
geometry: new ol.geom.LineString([start, end]),
//projection:'EPSG:4326',
})
];
styles.push(new ol.style.Style({
geometry: new ol.geom.Point([new_x, new_y]),
//projection:'EPSG:4326',
image: new ol.style.Icon({
src: 'images/myarrow_red.png',
anchor: [0.75, 0.5],
rotateWithView: true,
rotation: -rotation,
}),
}))
return styles
}
var velocity_1 = new ol.layer.Vector({
source: new ol.source.Vector({
url: 'data/geojson/velocity.geojson',
format: new ol.format.GeoJSON({ extractStyles: false }),
}),
style: this.styleFunction_1
})
velocity_1.setOpacity(0.5)
var velocity_2 = new ol.layer.Vector({
source: new ol.source.Vector({
url: 'data/geojson/velocity.geojson',
format: new ol.format.GeoJSON({ extractStyles: false }),
}),
style: this.styleFunction_2
})
velocity_2.setOpacity(0.5)
function velocity_addinteraction() {
//设置点击后样式
var velocity_selectpoint = new ol.interaction.Select({
layers: [velocity_1, velocity_2],
multi: true,
//hitolerance:4,
style: new ol.style.Style({
//因为把image打成Image又浪费了我半个小时
image: new ol.style.Circle({
radius: 6,
fill: new ol.style.Fill({
color: 'yellow'
})
})
})
})
//设置点击后事件
velocity_selectpoint.on('select', function (p) {
var features = p.target.getFeatures().getArray()//获取真正的featrue元素
if (features.length > 0) {
var obj = features[0];
console.log(obj.get('type'));//显示类型
var coordinate = p.mapBrowserEvent.coordinate
var property = obj.getProperties()//获取真正的属性信息
var geometry = obj.getGeometry();//获取地理数据信息
var json_obj = eval(obj)
//下面是摸索到的在geojson里面引用数据的方法,不知道直接用csv会不会简单点
var ftype = property["type"]
var ftitle = property["title"]
var otitle = obj.get('title')//事实证明这种获取方法默认是在properties下的数据
//properties数据引用
var station = property['Station']
var Ve_I = property['Ve_I']
var Ve_E = property['Ve_E']
var dVe = property['dVe']
var Vn_I = property['Vn_I']
var Vn_E = property['Vn_E']
var dVn = property['dVn']
var Cen = property['Cen']
var url = property['url']
//geometry下的数据只能这样引用
var geotype = geometry.getType();
var geocoordinates = geometry.getCoordinates();
var jwd = ol.proj.toLonLat(geocoordinates, 'EPSG:3857');
var fixed_1 = (jwd[0]).toFixed(3)
var fixed_2 = (jwd[1]).toFixed(3)
data_detail.innerHTML = `
<strong><p>GPS站点:`+ station + `</p></strong>
<p> </p>
<p>经纬度坐标:`+ fixed_1 + `,` + fixed_2 + `</p>
<p>东方向速率不确定值:`+ dVe + ` mm/yr</p>
<p>北方向速率不确定值:`+ dVn + ` mm/yr</p>
<p>两方向相关指数:`+ Cen + `</p>
`
popup_content.innerHTML = `
<p>GPS站点:`+ station + `</p>
<p>经纬度坐标:`+ fixed_1 + `,` + fixed_2 + `</p>
<p>基于ITRF2008</p>
<p>东方向形变速率:`+ Ve_I + ` mm/yr</p>
<p>北方向形变速率:`+ Vn_I + ` mm/yr</p>
<p>基于欧亚板块</p>
<p>东方向形变速率:`+ Ve_E + ` mm/yr</p>
<p>北方向形变速率:`+ Vn_E + ` mm/yr</p>
<p>东方向速率不确定值:`+ dVe + ` mm/yr</p>
<p>北方向速率不确定值:`+ dVn + ` mm/yr</p>
<p>两方向相关指数:`+ Cen + `</p>
`
overlay.setPosition(coordinate);//定义弹出框的位置