-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
62 lines (58 loc) · 1.86 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
<!DOCTYPE html><html lang="ja"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width">
<title>全国高専マップ - deck.gl version</title>
</head>
<body style="background-color: #224;">
<script type="module">
import { deck } from 'https://code4fukui.github.io/deck-es/deck.js';
import { GsiTerrainLayer } from 'https://code4fukui.github.io/deckgl-gsi-terrain-layer/index.js';
import { CSV } from "https://js.sabae.cc/CSV.js";
const url = "https://codeforkosen.github.io/kosen-opendata/data/kosen_campus.csv";
const data = await CSV.fetchJSON(url);
data.forEach(d => d.coordinates = [parseFloat(d.lng), parseFloat(d.lat)]);
const tooltipHandler = (e) => {
if (!e || !e.object) {
return null;
}
const obj = e.object;
const trs = Object.keys(obj)
.filter(key => obj[key])
.map(key => `<tr><th style="text-align:right">${key}</th><td>${obj[key]}</td></tr>`);
const html = ["<table>", ...trs, "</table>"].join("");
return {
html,
style: {
fontSize: "0.5em"
}
};
};
let isHovering = false;
const layer = new deck.ScenegraphLayer({
id: 'scenegraph-layer',
data,
pickable: true,
scenegraph: 'https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/BoxAnimated/glTF-Binary/BoxAnimated.glb',
getPosition: d => d.coordinates,
getOrientation: d => [0, Math.random() * 180, 90],
_animations: { '*': { speed: 5 } },
sizeScale: 5000,
_lighting: 'pbr',
onClick: e => window.open(e.object.URL, "_blank"),
});
new deck.Deck({
initialViewState: {
longitude: 135.98,
latitude: 35.75,
zoom: 6,
bearing: 20,
pitch: 70,
maxPitch: 85,
},
controller: true,
layers: [layer, new GsiTerrainLayer()],
onHover: e => isHovering = Boolean(e.object),
getCursor: e => e.isDragging ? 'grabbing' : (isHovering ? 'pointer' : 'grab'),
getTooltip: tooltipHandler,
});
</script>
</body>
</html>