-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path15min_fly.html
More file actions
101 lines (96 loc) · 2.68 KB
/
Copy path15min_fly.html
File metadata and controls
101 lines (96 loc) · 2.68 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>15-minute city 3D Map</title>
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" />
<script src="https://unpkg.com/maplibre-gl@3.6.2/dist/maplibre-gl.js"></script>
<link href="https://unpkg.com/maplibre-gl@3.6.2/dist/maplibre-gl.css" rel="stylesheet" />
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
</style>
</head>
<body>
<div id="map"></div>
<script>
const map = new maplibregl.Map({
container: 'map',
style: 'https://basemaps.cartocdn.com/gl/dark-matter-nolabels-gl-style/style.json',
/*style: {
version: 8,
sources: {},
layers: [{
id: 'background',
type: 'background',
paint: { 'background-color': '#000000' }
}]
},*/
center: [12.5, 41.9],
zoom: 10.5,
pitch: 60,
bearing: 0
});
// === Load CDI hex grid ===
map.on('load', () => {
fetch('rome_15min.geojson')
.then(r => r.json())
.then(data => {
map.addSource('hexes', { type: 'geojson', data: data });
map.addLayer({
id: 'hexes-3d',
type: 'fill-extrusion',
source: 'hexes',
paint: {
// height = scaled population
'fill-extrusion-height': [
'interpolate', ['linear'], ['get', 'population'],
0, 0,
1000, 2000,
5000, 4000,
10000, 5000,
],
// color = CDI red–white–blue scale
'fill-extrusion-color': [
'interpolate', ['linear'], ['get', '15min'],
1, '#0011cc',
15, '#ffffff',
40, '#cc0000'
],
'fill-extrusion-opacity': 0.65
}
});
console.log("✅ CDI hex grid added");
flySequence();
});
});
// === Fly through Rome ===
const stops = [
{ name: 'Rome', coords: [12.5, 41.85], zoom: 10.5, pitch: 35, bearing: 0},
{ name: 'Center Rome', coords: [12.5, 41.88], zoom: 11.65, pitch: 45, bearing: -10 },
{ name: 'Ostia', coords: [12.27, 41.75], zoom: 12.5, pitch: 50, bearing: 0 },
{ name: 'Acilia', coords: [12.36, 41.78], zoom: 12.5, pitch: 50, bearing: -40 },
{ name: 'Torri', coords: [12.66, 41.9], zoom: 12, pitch: 45, bearing: 25 },
{ name: 'Labaro', coords: [12.45, 42.02], zoom: 12, pitch: 55, bearing: -15 },
];
function flySequence() {
let i = 0;
function next() {
const s = stops[i];
map.flyTo({
center: s.coords,
zoom: s.zoom,
bearing: s.bearing,
pitch: s.pitch,
speed: 0.4,
curve: 1.6,
easing: t => t
});
i = (i + 1) % stops.length;
setTimeout(next, 8000); // 8 sec per move
}
next();
}
</script>
</body>
</html>