Cesium-Examples/examples/cesiumEx/实时在线云图.html
jiawanlong 00b47c684c 工具
2025-04-14 17:19:22 +08:00

120 lines
4.5 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!--********************************************************************
* by jiawanlong
*********************************************************************-->
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<link rel="stylesheet" href="./../../libs/cesium/Cesium1.98/Widgets/widgets.css">
<script type="text/javascript" src="./../../libs/cesium/Cesium1.98/Cesium.js"></script>
<script src="./echarts/5.4.3/echarts.min.js"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
</head>
<body style="margin: 0; overflow: hidden; background: #fff; width: 100%; height: 100%; position: absolute; top: 0">
<div id="map" style="margin: 0 auto; width: 100%; height: 100%"></div>
<div style=" position: absolute;bottom: 150px; width: 100%; left: 0%; z-index: 1000;">
<div id="timelines" style="width: 100%;height:50px;"></div>
</div>
<div style=" position: absolute;
right: 0;
bottom: 32px;
z-index: 100;
background: #373434fa;
color: white;
padding: 0 10px;
">
<p id="times" style=" font-size: 24px;"></p>
<p>注:数据来源于中央气象台与国家气象信息中心,中国天气网制图</p>
</div>
<script type="text/javascript">
Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI3ZjQ5ZGUzNC1jNWYwLTQ1ZTMtYmNjYS05YTY4ZTVmN2I2MDkiLCJpZCI6MTE3MTM4LCJpYXQiOjE2NzY0NDUyODB9.ZaNSBIfc1sGLhQd_xqhiSsc0yr8oS0wt1hAo9gbke6M'
const viewer = new Cesium.Viewer('map', {});
axios.get('https://gswarn.weather.com.cn/app/api/cn_scw_radar_cloud?type=satellite')
.then((response) => {
init(response.data.l);
})
function init(ddd) {
let arr1 = []
let arr2 = []
ddd.forEach((k)=>{
arr1.push(k.l1)
arr2.push(k.l2)
})
arr1 = arr1.reverse()
arr2 = arr2.reverse()
let arrTileLayer = [];
const urlArr = arr2;
for (let i = 0, len = urlArr.length; i < len; i++) {
var imageryProvider = new Cesium.SingleTileImageryProvider({
url: urlArr[i],
rectangle: Cesium.Rectangle.fromDegrees(63.05754, 4.432541, 136.963346, 54.174859),
});
let options = {
alpha: 0
}
var imageryLayer = new Cesium.ImageryLayer(imageryProvider, options);
viewer.imageryLayers.add(imageryLayer)
arrTileLayer.push(imageryLayer);
}
var myChart = echarts.init(document.getElementById('timelines'));
// echarts时间轴超级强大
var option = {
baseOption: {
timeline: {
axisType: 'category',
autoPlay: true,
playInterval: 100,
data: arr1,
label: {
formatter: function (s) {
return new Date(s).getHours() + "-" + new Date(s).getSeconds()
}
}
}
}
};
myChart.setOption(option);
myChart.on('timelinechanged', function (event) {
// console.log('当前:', event);
// console.log('当前索引:', event.currentIndex);
document.getElementById('times').innerHTML = "当前时间: "+ arr1 [event.currentIndex]
closeAll();
arrTileLayer[event.currentIndex].alpha = 1;
});
function closeAll() {
arrTileLayer.forEach((k, i) => {
arrTileLayer[i].alpha = 0;
})
}
viewer.camera.flyTo({
destination: Cesium.Cartesian3.fromDegrees(110.511154, 29.362943, 5531517.4),
duration: 2,
orientation: {
heading: Cesium.Math.toRadians(348.3), // 水平旋转围绕Y轴0为正北方向
pitch: Cesium.Math.toRadians(-89.8), // 上下旋转围绕X轴-90为俯视地面
roll: 0.0 // 视口的翻滚角度围绕Z轴0为不翻转
},
complete: () => {
}
});
}
</script>
</body>
</html>