-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
60 lines (56 loc) · 1.67 KB
/
index.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
<html>
<head>
<meta charset="utf-8"></meta>
<title>Example of Terrain-RGB</title>
<script src="https://api.mapbox.com/mapbox-gl-js/v1.13.0/mapbox-gl.js"></script>
<link href="https://api.mapbox.com/mapbox-gl-js/v1.13.0/mapbox-gl.css" rel="stylesheet"></link>
<style>
#map { position: absolute; top: 150; bottom: 0; width: 100%; }
.interaction {
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
border-radius: 3px;
padding: 10px;
margin-bottom: 10px;
}
.interaction input { width: 20%; }
</style>
</head>
<body>
<div class="interaction">
<h2>Direction</h2>
<input id="slider" type="range" min="0" max="360" step="1" value="0"></input>
</div>
<div id="map"></div>
<script>
var map = new mapboxgl.Map({
container: 'map', // container id
center: [121.5856, 25.0232], // starting position [lng, lat]
zoom: 9 // starting zoom
});
map.addSource('hillshading', {
"type": "raster-dem",
"tiles": [
"https://osmhacktw.github.io/terrain-rgb/tiles/{z}/{x}/{y}.png"
],
"tileSize": 256,
"maxzoom": 12
})
map.addLayer({
"id": "hillshading",
"type": "hillshade",
"source": "hillshading",
"minzoom": 6
});
map.on('load', function () {
document.getElementById('slider').addEventListener('input', function (e) {
console.log(e.target.value);
map.setPaintProperty(
'hillshading',
'hillshade-illumination-direction',
parseInt(e.target.value)
);
});
});
</script>
</body>
</html>