forked from htcvszrf/cesium-wind-1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
87 lines (75 loc) · 2.23 KB
/
index.js
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
var windy;
var started = false;
var viewer;
$(function(){
function initMap(target){
var osmMap = new Cesium.OpenStreetMapImageryProvider({
url : 'https://a.tile.openstreetmap.org/'
})
var viewer = new Cesium.Viewer(target, {
homeButton:true,
animation: false,
timeline: false,
infoBox: false,
selectionIndicator: false,
baseLayerPicker: true,
imageryProvider: osmMap,
terrainProviderViewModels: [],
geocoder: false,
vrButton: false,
navigationHelpButton: false,
mapProjection: new Cesium.WebMercatorProjection(),
sceneMode: Cesium.SceneMode.SCENE3D,
});
return viewer;
}
viewer = initMap("cesiumContainer");
window.cesiumGlobe = globe(viewer);
viewer._cesiumWidget._creditContainer.style.display="none";
$('#wind')[0].width = parseInt(viewer.canvas.width);
$('#wind')[0].height = parseInt(viewer.canvas.height);
function Draw() {
$.ajax({
type: "get",
url: "data/gfs.json",
dataType: "json",
success: function (response) {
windy = new Windy({ canvas: document.getElementById("wind"), data: response });
redraw();
},
error: function (errorMsg) {
alert("请求数据失败1!");
}
});
}
Draw();
function redraw(){
var width = viewer.canvas.width;
var height = viewer.canvas.height;
$('#wind')[0].width = width;
$('#wind')[0].height = height;
windy.stop();
// setTimeout(function(){
// },200);
started = windy.start(
[[0,0],[width, height]],
width,
height
);
$('#wind').show();
}
viewer.camera.moveStart.addEventListener(function(){
console.log("move start...");
$('#wind').hide();
if(!!windy && started){
windy.stop();
}
});
viewer.camera.moveEnd.addEventListener(function(){
console.log("move end...");
$('#wind').hide();
if(!!windy && started){
redraw();
}
});
});