-
Notifications
You must be signed in to change notification settings - Fork 9
/
basic_multiscale_tiled_CSV.html
35 lines (28 loc) · 1.28 KB
/
basic_multiscale_tiled_CSV.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
<div id="map" style="height: 500px; width: 800px"></div>
<script src="../../dist/gridviz.js"></script>
<script>
//define map with initial view
const map = new gridviz.Map(document.getElementById('map'), { x: 4500000, y: 2900000, z: 3000 })
.addZoomButtons()
//define multi resolution dataset
const dataset = new gridviz.MultiResolutionDataset(
//the resolutions
[1000, 2000, 5000, 10000, 20000, 50000, 100000],
//the function returning each dataset from the resolution
resolution => new gridviz.TiledGrid(map, 'https://raw.githubusercontent.com/jgaffuri/tiledgrids/main/data/europe/population2/' + resolution + 'm/')
)
//define color for each cell c
const colorFunction = (cell, resolution) => {
const density = 1000000 * cell.TOT_P_2021 / (resolution * resolution)
if (density > 1500) return "#993404"
else if (density > 600) return "#d95f0e"
else if (density > 200) return "#fe9929"
else if (density > 60) return "#fec44f"
else if (density > 15) return "#fee391"
else return "#ffffd4"
}
//define style
const style = new gridviz.ShapeColorSizeStyle({ color: colorFunction })
//add layer to map
map.layers = [new gridviz.GridLayer(dataset, [style])]
</script>