diff options
author | Hsieh Chin Fan <pham@topo.tw> | 2024-10-06 12:06:27 +0800 |
---|---|---|
committer | Hsieh Chin Fan <pham@topo.tw> | 2024-10-06 12:06:27 +0800 |
commit | 1b37f7d7f1554f4ef4cd185c1181d54d9956b1db (patch) | |
tree | 54057c5cee90f3a93b240d77828f14f90af8c93f /snippets/js_maplibre_terrain | |
parent | a9386c536189f2aaf38c9e2ba674a096657ca366 (diff) |
Update
Diffstat (limited to 'snippets/js_maplibre_terrain')
-rw-r--r-- | snippets/js_maplibre_terrain | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/snippets/js_maplibre_terrain b/snippets/js_maplibre_terrain new file mode 100644 index 0000000..a6466db --- /dev/null +++ b/snippets/js_maplibre_terrain | |||
@@ -0,0 +1,27 @@ | |||
1 | map.addSource('hillshading', { | ||
2 | "type": "raster-dem", | ||
3 | "tiles": [ | ||
4 | "https://osmhacktw.github.io/terrain-rgb/tiles/{z}/{x}/{y}.png" | ||
5 | ], | ||
6 | "tileSize": 256, | ||
7 | "maxzoom": 12 | ||
8 | }); | ||
9 | map.setTerrain({ 'source': 'hillshading', 'exaggeration': 1.5 }); | ||
10 | |||
11 | map.addLayer({ | ||
12 | "id": "hillshading", | ||
13 | "type": "hillshade", | ||
14 | "source": "hillshading", | ||
15 | "minzoom": 6 | ||
16 | }); | ||
17 | |||
18 | map.on('load', function () { | ||
19 | document.getElementById('slider').addEventListener('input', function (e) { | ||
20 | console.log(e.target.value); | ||
21 | map.setPaintProperty( | ||
22 | 'hillshading', | ||
23 | 'hillshade-illumination-direction', | ||
24 | parseInt(e.target.value) | ||
25 | ); | ||
26 | }); | ||
27 | }); | ||