forked from mapbox/mapbox-gl-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_image.html
69 lines (58 loc) · 1.45 KB
/
update_image.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
<!DOCTYPE html>
<html>
<head>
<title>Mapbox GL JS debug page</title>
<meta charset='utf-8'>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<link rel='stylesheet' href='../dist/mapbox-gl.css' />
<style>
body { margin: 0; padding: 0; }
html, body, #map { height: 100%; }
</style>
</head>
<body>
<div id='map'></div>
<script src='../dist/mapbox-gl-dev.js'></script>
<script src='../debug/access_token_generated.js'></script>
<script>
const map = new mapboxgl.Map({
container: 'map',
minZoom: 1,
zoom: 6,
center: [-76, 43.5],
style: 'mapbox:https://styles/mapbox/dark-v9',
hash: false
});
const path = "/docs/pages/assets/";
const frameCount = 5;
const coordinates = [
[-80.425, 46.437],
[-71.516, 46.437],
[-71.516, 37.936],
[-80.425, 37.936]
];
map.on("load", () => {
let currentImage = 0;
const getPath = () => `${path}radar${currentImage}.gif`;
map.addSource("radar", {
type: "image",
url: getPath(),
coordinates
});
map.addLayer({
id: "radar-layer",
"type": "raster",
"source": "radar",
"paint": {
"raster-resampling": "nearest",
"raster-fade-duration": 0
}
});
setInterval(() => {
currentImage = (currentImage + 1) % frameCount;
map.getSource("radar").updateImage({url: getPath()});
}, 200);
});
</script>
</body>
</html>