-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
80 lines (74 loc) · 2.15 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
<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width">
<title>鯖江のまち</title>
<meta name="format-detection" content="telephone=no">
<link rel="stylesheet" href="https://code4sabae.github.io/leaflet-mjs/leaflet.css">
<script type="module">
import L from 'https://code4sabae.github.io/leaflet-mjs/leaflet.mjs'
import { Geo3x3 } from "https://geo3x3.com/Geo3x3.js";
import { TownID } from "https://code4fukui.github.io/TownID/TownID.js";
const pref = "福井県";
const city = "鯖江市";
onload = async () => {
const map = L.map("mapid");
// set 国土地理院地図 https://maps.gsi.go.jp/development/ichiran.html
L.tileLayer("https://cyberjapandata.gsi.go.jp/xyz/std/{z}/{x}/{y}.png", {
attribution: '<a href="https://maps.gsi.go.jp/development/ichiran.html">国土地理院</a>"',
maxZoom: 18,
}).addTo(map);
const iconlayer = L.layerGroup();
iconlayer.addTo(map);
const lls = [];
const towns = await TownID.getTowns(pref, city);
console.log(towns);
const iconfn = "https://code4sabae.github.io/towns/icon/icon-home2.png";
const icon = L.icon({
iconUrl: iconfn,
iconRetinaUrl: iconfn,
iconSize: [32, 32],
iconAnchor: [16, 16],
popupAnchor: [0, -16],
});
for (const town of towns) {
const geo3x3 = await TownID.find(pref, city, town);
const pos = Geo3x3.decode(geo3x3);
const ll = [pos.lat, pos.lng];
const marker = L.marker(ll, { title: town, icon })
marker.bindPopup(town + " " + geo3x3);
iconlayer.addLayer(marker);
lls.push(ll);
}
if (lls.length) {
map.fitBounds(lls);
}
};
</script>
<style>
body {
margin: 0px;
text-align: center;
box-sizing: border-box; /* width include border */
-webkit-text-size-adjust: none; /* for iPhone */
}
#mapid {
width: 100%;
height: 60vh;
}
#credit a {
color: gray !important;
text-decoration: none;
}
#credit {
margin-top: 1em;
font-size: 80%;
}
</style>
</head>
<body>
<h1>鯖江のまち</h1>
<div id="mapid"></div>
<div id="credit">
DATA: CC BY <a href=https://github.com/code4fukui/TownID/>TownID by Code for Fukui</a><br>
APP: CC BY <a href=http://fukuno.jig.jp/3249>福野泰介 一日一創</a><br>
</div>
</body>
</html>