forked from Esri/wind-js
-
Notifications
You must be signed in to change notification settings - Fork 1
/
layered.html
128 lines (110 loc) · 3.93 KB
/
layered.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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
<title>Wind Animation</title>
<link rel="stylesheet" href="http://js.arcgis.com/3.8/js/esri/css/esri.css">
<link rel="stylesheet" href="css/style.css">
<script>
var dojoConfig = {
paths: {
plugins: location.pathname.replace(/\/[^/]+$/, "") + "/plugins"
}
};
</script>
<script src="./windy.js"></script>
<script src="http://js.arcgis.com/3.8compact/"></script>
<script>
var map, rasterLayer;
var canvasSupport;
require([
"esri/map", "esri/layers/ArcGISTiledMapServiceLayer",
"esri/domUtils", "esri/request",
"dojo/parser", "dojo/number", "dojo/json", "dojo/dom",
"dijit/registry", "plugins/RasterLayer","esri/layers/WebTiledLayer",
"esri/config",
"dojo/domReady!"
], function(
Map, ArcGISTiledMapServiceLayer,
domUtils, esriRequest,
parser, number, JSON, dom,
registry, RasterLayer, WebTiledLayer, esriConfig
){
parser.parse();
// does the browser support canvas?
canvasSupport = supports_canvas();
// hook up elevation slider events
esriConfig.defaults.map.basemaps.darkgray = {
baseMapLayers: [
{ url: "http://tiles4.arcgis.com/tiles/P3ePLMYs2RVChkJx/arcgis/rest/services/World_Dark_Gray_Base_Beta/MapServer" }
],
title: "Dark Gray"
};
map = new Map("mapCanvas-map", {
center: [-99.076, 39.132],
zoom: 3,
basemap: "darkgray"
});
map2 = new Map("mapCanvas", {
center: [-99.076, 39.132],
zoom: 3,
basemap: ""
});
map.on("load", mapLoaded);
function mapLoaded() {
// Add raster layer
if ( canvasSupport ) {
rasterLayer = new RasterLayer(null, {
opacity: 0.8
});
map2.addLayer(rasterLayer);
map2.on("extent-change", redraw);
map2.on("resize", function(){});
map.on("extent-change", redraw);
map.on("resize", function(){});
var layersRequest = esriRequest({
url: './gfs.json',
content: {},
handleAs: "json"
});
layersRequest.then(
function(response) {
//console.log("Success: ", arguments);
windy = new Windy({ canvas: rasterLayer._element, data: response });
redraw();
}, function(error) {
console.log("Error: ", error.message);
});
} else {
dom.byId("mapCanvas-map").innerHTML = "This browser doesn't support canvas. Visit <a target='_blank' href='http://www.caniuse.com/#search=canvas'>caniuse.com</a> for supported browsers";
}
}
// does the browser support canvas?
function supports_canvas() {
return !!document.createElement("canvas").getContext;
}
function redraw(){
rasterLayer._element.width = map2.width;
rasterLayer._element.height = map2.height;
windy.stop();
var extent = map.geographicExtent;
setTimeout(function(){
windy.start(
[[0,0],[map.width, map.height]],
map.width,
map.height,
[[extent.xmin, extent.ymin],[extent.xmax, extent.ymax]]
);
},500);
}
});
</script>
</head>
<body class="">
<div class="parent perspective">
<div id="mapCanvas-map"></div>
<div id="mapCanvas"></div>
</div>
</body>
</html>