-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
613 lines (464 loc) · 14.9 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
<!DOCTYPE html>
<html lang="en">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
<link href="https://unpkg.com/[email protected]/dist/maplibre-gl.css" rel="stylesheet" />
<script src="https://unpkg.com/[email protected]/dist/maplibre-gl.js"></script>
<script src="https://unpkg.com/[email protected]/dist/flatgeobuf-geojson.min.js"></script>
<style>
body { margin:0; padding:0; }
#map {
position: absolute;
top: 0;
bottom: 0;
width: 100%;
}
#basemaps-selecter {
position: absolute;
top: 20px;
left: 20px;
background: rgba(255, 255, 255, 0);
z-index:255;
}
#basemaps {
font-size: 16px;
padding: 4px 8px;
}
#tablearea {
position: absolute;
bottom: 0;
width: 100%;
height: 200px;
z-index:255;
box-shadow: 0 0 50px -25px black;
background: white;
display:none;
}
#elink{
font: 12px/20px 'Helvetica Neue', Arial, Helvetica, sans-serif;
}
</style>
<style>
.listing-group {
font: 12px/20px 'Helvetica Neue', Arial, Helvetica, sans-serif;
font-weight: 600;
position: absolute;
top: 10px;
left: 10px;
z-index: 1;
border-radius: 3px;
max-width: 100%;
color: #fff;
}
.listing-group input[type='checkbox']:first-child + label {
border-radius: 3px 3px 0 0;
}
.listing-group label:last-child {
border-radius: 0 0 3px 3px;
border: none;
}
.listing-group input[type='checkbox'] {
display: none;
}
.listing-group input[type='checkbox'] + label {
background-color: #3386c0;
display: block;
cursor: pointer;
padding: 10px;
border-bottom: 1px solid rgba(0, 0, 0, 0.25);
}
.listing-group input[type='checkbox'] + label {
background-color: #3386c0;
text-transform: capitalize;
}
.listing-group input[type='checkbox'] + label:hover,
.listing-group input[type='checkbox']:checked + label {
background-color: #4ea0da;
}
.listing-group input[type='checkbox']:checked + label:before {
content: '✔';
margin-right: 5px;
}
</style>
<style>
.rounded-rect {
background: white;
border-radius: 10px;
box-shadow: 0 0 50px -25px black;
}
.flex-center {
position: absolute;
display: flex;
justify-content: center;
align-items: center;
}
.flex-center.left {
left: 0px;
}
.flex-center.right {
right: 0px;
}
.sidebar-content {
position: absolute;
width: 95%;
height: 95%;
font-family: Arial, Helvetica, sans-serif;
font-size: 32px;
color: gray;
}
.sidebar-toggle {
position: absolute;
width: 1.3em;
height: 1.3em;
overflow: visible;
display: flex;
justify-content: center;
align-items: center;
}
.sidebar-toggle.left {
right: -1.5em;
}
.sidebar-toggle.right {
left: -1.5em;
}
.sidebar-toggle:hover {
color: #0aa1cf;
cursor: pointer;
}
.sidebar {
transition: transform 1s;
z-index: 1;
width: 300px;
height: 100%;
}
/*
The sidebar styling has them "expanded" by default, we use CSS transforms to push them offscreen
The toggleSidebar() function removes this class from the element in order to expand it.
*/
.left.collapsed {
transform: translateX(-295px);
}
.right.collapsed {
transform: translateX(295px);
}
</style>
</head>
<body>
<div id="map">
<div id="basemaps-selecter">
<select id="basemaps">
<!-- <option value="blank">地理院タイル白地図</option> -->
<option value="pale">地理院タイル skelton</option>
<!-- <option value="std">地理院タイル標準</option>
<option value="gsi_3d">地理院タイル3D風</option>
<option value="std_vertical">地理院タイル標準縦書きあり</option>
-->
<option value="gsi_photo">地理院タイル写真</option>
</select>
</div>
<div id="left" class="sidebar flex-center left collapsed">
<div class="sidebar-content rounded-rect flex-center">
<div
class="sidebar-toggle rounded-rect left"
onclick="toggleSidebar('left')"
id="la"
>
→
</div>
</div>
</div>
<div id="right" class="sidebar flex-center right collapsed">
<div class="sidebar-content rounded-rect flex-center">
<nav id="listing-group" class="listing-group">
<input type="checkbox" id="sougou_kikendo" checked="checked" />
<label for="sougou_kikendo">総合危険度ランク</label>
<input type="checkbox" id="toukai_kikendo" />
<label for="toukai_kikendo">建物倒壊危険度ランク</label>
<input type="checkbox" id="kasai_kikendo" />
<label for="kasai_kikendo">火災危険度ランク</label>
<input type="checkbox" id="jiban" />
<label for="jiban">地盤分類</label>
</nav>
<table>
<tr><td>
<div id="rank">
<h5>危険度ランク</h5>
<br>
<img src="./data/rank.png" width="250">
</div>
</td></tr>
<tr><td>
<div id="jiban">
<h5>地盤分類</h5>
<br>
<img src="./data/jibanlegend.png" width="250">
</div>
</td></tr>
<tr><td>
<br><br>
<div id="elink">
詳しくは<a href=" https://www.toshiseibi.metro.tokyo.lg.jp/bosai/chousa_6/home.htm" target="_other">地震に関する地域危険度測定調査(東京都)</a>を参照してください。
<br>参考<a href="https://www.toshiseibi.metro.tokyo.lg.jp/bosai/chousa_6/download/mikata.pdf">地域危険度一覧表の見方</a>
</div>
</td>
</table>
<div
class="sidebar-toggle rounded-rect right"
onclick="toggleSidebar('right')"
id="ra"
>
←
</div>
</div>
</div>
<div id="tablearea" >
</div>
</div>
<script>
function toggleSidebar(id) {
var elem = document.getElementById(id);
var classes = elem.className.split(' ');
var collapsed = classes.indexOf('collapsed') !== -1;
var left = classes.indexOf('left') !== -1;
var padding = {};
if (collapsed) {
// Remove the 'collapsed' class from the class list of the element, this sets it back to the expanded state.
classes.splice(classes.indexOf('collapsed'), 1);
padding[id] = 300; // In px, matches the width of the sidebars set in .sidebar CSS class
if ( left ){
//alert('left');
var lftbtn = document.getElementById("la");
lftbtn.innerHTML = "←";
}
else {
//alert('right');
var rigbtn = document.getElementById("ra");
rigbtn.innerHTML = "→";
}
map.easeTo({
padding: padding,
duration: 1000 // In ms, CSS transition duration property for the sidebar matches this value
});
} else {
padding[id] = 0;
// Add the 'collapsed' class to the class list of the element
classes.push('collapsed');
if ( left ){
var lftbtn = document.getElementById("la");
lftbtn.innerHTML = "→";
}
else {
//alert('right');
var rigbtn = document.getElementById("ra");
rigbtn.innerHTML = "←";
}
map.easeTo({
padding: padding,
duration: 1000
});
}
// Update the class list on the element
elem.className = classes.join(' ');
}
var map = new maplibregl.Map({
container: "map",
style: './skeleton.json',
center: [139.581367, 35.695671],
zoom: 11,
maxZoom: 18,
});
const setBasemap = (name) => {
// Instantiate the given basemap layer.
// map.setStyle(base_maps[name]);
if (name == 'gsi_photo'){
console.log('gsi');
map.setLayoutProperty(name, 'visibility', 'visible');
}
else {
map.setLayoutProperty('gsi_photo', 'visibility', 'none');
}
};
const basemapsSelectElement = document.querySelector("#basemaps");
basemapsSelectElement.addEventListener("change", (e) => {
setBasemap(e.target.value);
// map.triggerRepaint();
});
map.addControl(new maplibregl.NavigationControl(), 'bottom-right');
map.addControl(new maplibregl.ScaleControl() );
loadfgb();
// load flat geobuff file
async function loadfgb(){
const response = await fetch("./data/tokyorisk5.fgb")
map.on("load", async () => {
map.addSource('gsi_raster', {
'type': 'raster',
tiles: [
'https://cyberjapandata.gsi.go.jp/xyz/seamlessphoto/{z}/{x}/{y}.jpg',
],
'tileSize': 256,
'attribution':
'国土地理院',
});
map.addLayer({
'id':'gsi_photo',
'type':'raster',
'source':'gsi_raster',
'minzoom':5,
'maxzoom':18,
'layout':{
'visibility':'none'
},
paint:{ "raster-opacity": 1.0}
});
const fc = {type: "FeatureCollection", features: []};
for await (const f of flatgeobuf.deserialize(response.body))
fc.features.push(f);
map.addSource("tokyorisk", {
type: "geojson",
data: fc,
'attribution':
'東京都',
});
map.addLayer({
id: "sougou_kikendo",
type: "fill",
source: "tokyorisk",
paint: {
"fill-color": {
property: "総合危険度_ランク",
type: 'categorical',
stops: [
[1, '#95d3e8'],
[2, '#70ac70'],
[3, '#da8312'],
[4, '#e92b14'],
[5, '#590b10'],
]
},
"fill-opacity": 0.6,
},
layout: {
visibility: 'visible'
},
});
map.addLayer({
id: "toukai_kikendo",
type: "fill",
source: "tokyorisk",
paint: {
"fill-color": {
property: "建物倒壊危険度_ランク",
type: 'categorical',
stops: [
[1, '#95d3e8'],
[2, '#70ac70'],
[3, '#da8312'],
[4, '#e92b14'],
[5, '#590b10'],
]
},
"fill-opacity": 0.6,
},
layout: {
visibility: 'none'
},
});
map.addLayer({
id: "kasai_kikendo",
type: "fill",
source: "tokyorisk",
paint: {
"fill-color": {
property: "火災危険度_ランク",
type: 'categorical',
stops: [
[1, '#95d3e8'],
[2, '#70ac70'],
[3, '#da8312'],
[4, '#e92b14'],
[5, '#590b10'],
]
},
"fill-opacity": 0.6,
},
layout: {
visibility: 'none'
},
});
map.addLayer({
id: "jiban",
type: "fill",
source: "tokyorisk",
paint: {
"fill-color": {
property: "地盤分類",
type: 'categorical',
stops: [
["沖積低地1", '#755fa9'],
["沖積低地2", '#abd15a'],
["沖積低地3", '#f0f194'],
["沖積低地4", '#f9c696'],
["沖積低地5", '#f69782'],
["丘陵", '#4e4f29'],
["山地", '#f79c5b'],
["台地1", '#5181c1'],
["台地2", '#328042'],
["谷底低地1", '#9dd9dd'],
["谷底低地2", '#bba4cf'],
["谷底低地3", '#ee65a7'],
]
},
"fill-opacity": 0.6,
},
layout: {
visibility: 'none'
},
});
map.addLayer({
id: "risk-line",
type: "line",
source: "tokyorisk",
paint: {
"line-color": "#888888",
"line-opacity": 0.9,
"line-width": 1,
},
});
});
}
// When a click event occurs on a feature in the places layer, open a popup at the
// location of the feature, with description HTML from its properties.
map.on('click', 'sougou_kikendo', function (e) {
//var coordinates = e.features[0].geometry.coordinates.slice();
console.log('A click event has occurred at ' + e.lngLat);
var tghtml = "<table><TH>項目</TH><TH>値</TH>";
for ( var key in e.features[0].properties ){
tghtml = tghtml + "<TR><td>" + key + "</td><td>" + e.features[0].properties[key] + "</td></tr>";
}
tghtml = tghtml + "</table>";
//var description = e.features[0].properties["総合危険度_ランク"];
//console.log(e.features[0].properties["history"]);
// Ensure that if the map is zoomed out such that multiple
// copies of the feature are visible, the popup appears
// over the copy being pointed to.
//while (Math.abs(e.lngLat.lng - coordinates[0]) > 180) {
//coordinates[0] += e.lngLat.lng > coordinates[0] ? 360 : -360;
//}
new maplibregl.Popup()
.setLngLat(e.lngLat)
.setHTML(tghtml)
.addTo(map);
});
document
.getElementById('listing-group')
.addEventListener('change', function (e) {
var layername = e.target.id;
if (e.target.checked) {
map.setLayoutProperty(layername, 'visibility', 'visible');
} else {
map.setLayoutProperty(layername, 'visibility', 'none');
}
});
</script>
</body>
</html>