-
Notifications
You must be signed in to change notification settings - Fork 0
/
index2.html
85 lines (80 loc) · 1.96 KB
/
index2.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
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title>Population Density</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.53.1/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.53.1/mapbox-gl.css' rel='stylesheet' />
<link rel="stylesheet" href="style.css" />
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
</style>
</head>
<body>
<div class="floater">
<ul class="leg-list">
<li id="rain"><span style='background: #FFF8FD; opacity: .9;'></span>Low Density</li>
<br>
<li id="tree"><span style='background: #FF00BD; opacity: .5'></span>Medium Density</li>
<br>
<li id="other"><span style='background:#FF00BD; opacity: 0.9'></span>High Density</li>
<br>
</ul>
<h4 class="desc">Colors fade to blue upon zoom; shades remain the same</h4>
</div>
<div id='map'></div>
<script>
mapboxgl.accessToken = 'pk.eyJ1Ijoic3RyZWV0ZmlnaHRzIiwiYSI6ImNqdGtlZ2QyZDM5dnozem8zMnQ0MmNxcTgifQ.4HRlIEHjijTwMlVWGkoENw';
var map = new mapboxgl.Map({
container: 'map', // container id
style: 'mapbox://styles/streetfights/cjttyipph0u0i1hny7j1lk1dk', // stylesheet location
center: [30.0222, -1.9596], // starting position [lng, lat]
zoom: 7 // starting zoom
});
map.on('load', function () {
map.addLayer({
'id': 'rwanda-provinces',
'type': 'fill',
'source': {
'type': 'geojson',
'data': 'https://docs.mapbox.com/mapbox-gl-js/assets/rwanda-provinces.geojson'
},
'layout': {},
'paint': {
'fill-color':
["let", "density", ["/", ["get", "population"], ["get", "sq-km"]],
[
"interpolate",
["linear"],
["zoom"],
8,
[
"interpolate",
["linear"],
["var", "density"],
274,
["to-color", "#edf8e9"],
1551,
["to-color", "#FF00BD"]
],
10,
[
"interpolate",
["linear"],
["var", "density"],
274,
["to-color", "#eff3ff"],
1551,
["to-color", "#08519c"]
]
]
],
'fill-opacity': .7
}
});
});
</script>
</body>
</html>