1+ <!--********************************************************************
2+ * by jiawanlong
3+ *********************************************************************-->
4+ <!DOCTYPE html>
5+ < html >
6+
7+ < head >
8+ < meta charset ="UTF-8 " />
9+ < link rel ="stylesheet " href ="./../../libs/cesium/Cesium1.98/Widgets/widgets.css ">
10+ < script type ="text/javascript " src ="./../../libs/cesium/Cesium1.98/Cesium.js "> </ script >
11+ < script src ="./echarts/5.4.3/echarts.min.js "> </ script >
12+ < script src ="https://unpkg.com/axios/dist/axios.min.js "> </ script >
13+ </ head >
14+
15+ < body style ="margin: 0; overflow: hidden; background: #fff; width: 100%; height: 100%; position: absolute; top: 0 ">
16+ < div id ="map " style ="margin: 0 auto; width: 100%; height: 100% "> </ div >
17+ < div style =" position: absolute;bottom: 150px; width: 100%; left: 0%; z-index: 1000; ">
18+ < div id ="timelines " style ="width: 100%;height:50px; "> </ div >
19+ </ div >
20+ < div style =" position: absolute;
21+ right: 0;
22+ bottom: 32px;
23+ z-index: 100;
24+ background: #373434fa;
25+ color: white;
26+ padding: 0 10px;
27+ ">
28+ < p id ="times " style =" font-size: 24px; "> </ p >
29+ < p > 注:数据来源于中央气象台与国家气象信息中心,中国天气网制图</ p >
30+ </ div >
31+ < script type ="text/javascript ">
32+
33+ Cesium . Ion . defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI3ZjQ5ZGUzNC1jNWYwLTQ1ZTMtYmNjYS05YTY4ZTVmN2I2MDkiLCJpZCI6MTE3MTM4LCJpYXQiOjE2NzY0NDUyODB9.ZaNSBIfc1sGLhQd_xqhiSsc0yr8oS0wt1hAo9gbke6M'
34+ const viewer = new Cesium . Viewer ( 'map' , { } ) ;
35+
36+ axios . get ( 'https://gswarn.weather.com.cn/app/api/cn_scw_radar_cloud?type=satellite' )
37+ . then ( ( response ) => {
38+ init ( response . data . l ) ;
39+ } )
40+ function init ( ddd ) {
41+ let arr1 = [ ]
42+ let arr2 = [ ]
43+ ddd . forEach ( ( k ) => {
44+ arr1 . push ( k . l1 )
45+ arr2 . push ( k . l2 )
46+ } )
47+ arr1 = arr1 . reverse ( )
48+ arr2 = arr2 . reverse ( )
49+
50+ let arrTileLayer = [ ] ;
51+ const urlArr = arr2 ;
52+ for ( let i = 0 , len = urlArr . length ; i < len ; i ++ ) {
53+ var imageryProvider = new Cesium . SingleTileImageryProvider ( {
54+ url : urlArr [ i ] ,
55+ rectangle : Cesium . Rectangle . fromDegrees ( 63.05754 , 4.432541 , 136.963346 , 54.174859 ) ,
56+ } ) ;
57+
58+ let options = {
59+ alpha : 0
60+ }
61+ var imageryLayer = new Cesium . ImageryLayer ( imageryProvider , options ) ;
62+ viewer . imageryLayers . add ( imageryLayer )
63+
64+ arrTileLayer . push ( imageryLayer ) ;
65+ }
66+
67+ var myChart = echarts . init ( document . getElementById ( 'timelines' ) ) ;
68+
69+ // echarts时间轴,超级强大!
70+ var option = {
71+ baseOption : {
72+ timeline : {
73+ axisType : 'category' ,
74+ autoPlay : true ,
75+ playInterval : 1000 ,
76+ data : arr1 ,
77+ label : {
78+ formatter : function ( s ) {
79+ return new Date ( s ) . getHours ( ) + "-" + new Date ( s ) . getSeconds ( )
80+ }
81+ }
82+ }
83+ }
84+ } ;
85+
86+ myChart . setOption ( option ) ;
87+
88+ myChart . on ( 'timelinechanged' , function ( event ) {
89+ // console.log('当前:', event);
90+ // console.log('当前索引:', event.currentIndex);
91+ document . getElementById ( 'times' ) . innerHTML = "当前时间: " + arr1 [ event . currentIndex ]
92+ closeAll ( ) ;
93+ arrTileLayer [ event . currentIndex ] . alpha = 1 ;
94+ } ) ;
95+
96+ function closeAll ( ) {
97+ arrTileLayer . forEach ( ( k , i ) => {
98+ arrTileLayer [ i ] . alpha = 0 ;
99+ } )
100+ }
101+
102+ viewer . camera . flyTo ( {
103+ destination : Cesium . Cartesian3 . fromDegrees ( 110.511154 , 29.362943 , 5531517.4 ) ,
104+ duration : 2 ,
105+ orientation : {
106+ heading : Cesium . Math . toRadians ( 348.3 ) , // 水平旋转,围绕Y轴,0为正北方向
107+ pitch : Cesium . Math . toRadians ( - 89.8 ) , // 上下旋转,围绕X轴,-90为俯视地面
108+ roll : 0.0 // 视口的翻滚角度,围绕Z轴,0为不翻转
109+ } ,
110+ complete : ( ) => {
111+
112+ }
113+ } ) ;
114+ }
115+
116+
117+ </ script >
118+ </ body >
119+
120+ </ html >
0 commit comments