forked from furuhashilab/UNVT_for_Tokyo-to
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
137 lines (134 loc) · 4.47 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
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>東京都 避難所マップ</title>
<script src="https://unpkg.com/[email protected]/dist/maplibre-gl.js"></script>
<link
href="https://unpkg.com/[email protected]/dist/maplibre-gl.css"
rel="stylesheet"
/>
<style>
html,
body,
#map {
width: 100vw;
height: 100vh;
padding: 0;
margin: 0;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
(async () => {
let map;
const res = await fetch("./tiles.json");
const tilejson = await res.json();
const bounds = tilejson.bounds;
const center = tilejson.center
? tilejson.center
: [(bounds[0] + bounds[2]) / 2, (bounds[1] + bounds[3]) / 2];
const zoom = (tilejson.minzoom + tilejson.maxzoom) / 2;
console.log(center, zoom);
map = new maplibregl.Map({
container: "map",
style: "./style.json",
center: center,
zoom: 10,
});
map.on("load", function () {
map.loadImage(
"https://furuhashilab.github.io/2021gsc_ShogoHirasawa/image/house.png",
function (error, image) {
if (error) throw error;
map.addImage("evacuation", image);
map.addControl(new maplibregl.NavigationControl());
map.addControl(
new maplibregl.GeolocateControl({
positionOptions: {
enableHighAccuracy: false,
},
fitBoundsOptions: { maxZoom: 6 },
trackUserLocation: true,
showUserLocation: true,
})
);
map.addSource("evacuationes", {
type: "geojson",
data: "https://furuhashilab.github.io/UNVT_for_Tokyo-to/data/evacuation_center_Tokyo.geojson",
cluster: true,
clusterMaxZoom: 14,
clusterRadius: 50,
});
map.addLayer({
id: "clusters",
type: "circle",
source: "evacuationes",
minzoom: 0,
maxzoom: 22,
filter: ["has", "point_count"],
paint: {
"circle-color": [
"step",
["get", "point_count"],
"#51bbd6",
30,
"#f1f075",
100,
"#f28cb1",
],
"circle-radius": [
"step",
["get", "point_count"],
20,
30,
30,
100,
40,
],
},
});
map.addLayer({
id: "cluster-count",
type: "symbol",
source: "evacuationes",
filter: ["has", "point_count"],
layout: {
"text-field": "{point_count}",
"text-font": ["Open Sans Regular"],
"text-size": 12,
},
});
map.addLayer({
id: "unclustered-point",
type: "circle",
source: "evacuationes",
filter: ["!", ["has", "point_count"]],
paint: {
"circle-color": "#ff0000",
"circle-radius": 7,
"circle-stroke-width": 4,
"circle-stroke-color": "#fff",
},
});
}
);
});
map.addControl(new maplibregl.NavigationControl());
map.addControl(
new maplibregl.AttributionControl({
compact: false,
customAttribution:
"Style © <a href='http://openmaptiles.org/'>OpenMapTiles</a> | " +
"Data © <a href='http://www.openstreetmap.org/copyright'>OpenStreetMap contributors</a> " +
"© <a href='https://catalog.data.metro.tokyo.lg.jp/dataset/t000003d0000000093?fbclid=IwAR3iaIsI7e0rmSCiyZoNaw6GaiX1dqd87qXnSDoosOWYNd1kbWoNHdVF1xI'>東京都オープンデータカタログサイト<a>",
})
);
})();
</script>
</body>
</html>