-
Notifications
You must be signed in to change notification settings - Fork 151
/
Copy pathkyotoishibumimap-bk.html
200 lines (191 loc) · 6.1 KB
/
kyotoishibumimap-bk.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
<!DOCTYPE html><html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="apple-touch-icon" href="kyotoishibumimap.jpg" />
<meta property="og:image" content="kyotoishibumimap.jpg" />
<title>全1470個所 いしぶみマップ - 京都市オープンデータ x egmapjs</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" integrity="sha512-puBpdR0798OZvTTbP4A8Ix/l+A4dHDD0DGqYW6RQ+9jxkRFclaxxQb/SJAWZfWAkuyeQUytO7+7N4QKrDh+drA==" crossorigin=""/>
<script src="https://unpkg.com/[email protected]/dist/leaflet.js" integrity="sha512-QVftwZFqvtRNi0ZyCtsznlKSWOStnDORoefr1enyq5mVL4tmKB3S/EnC3rRJcxCPavG10IcrVGSmPh6Qw5lwrg==" crossorigin=""></script>
<script src="https://code4fukui.github.io/egmapjs/egmap.js"></script>
<script src="https://fukuno.jig.jp/fukuno.js"></script>
<script>"use strict"
const convertJP2WGS = function(o) {
if (!o.lat || !o.lng)
return
const lat2 = o.lat - o.lat * 0.00010695 + o.lng * 0.000017464 + 0.0046017
const lng2 = o.lng - o.lat * 0.000046038 - o.lng * 0.000083043 + 0.010040
o.lat = lat2
o.lng = lng2
}
// script src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.4.4/proj4.js"
/*
proj4.defs([
["EPSG:4301", //東京測地系/日本測地系 SRID=4301
"+proj=longlat +ellps=bessel +towgs84=-146.414,507.337,680.507,0,0,0,0 +no_defs"
],
["EPSG:4612", //日本測地系/JGD2000 SRID=4612
"+proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs"
]
]);
*/
function convertTokyo2WGS(o) {
if (!o.lat || !o.lng)
return
let ret = proj4("EPSG:4301", "EPSG:4326", [ parseFloat(o.lng), parseFloat(o.lat) ])
o.lat = ret[1]
o.lng = ret[0]
}
const convertDMS2D = function(o) {
if (!o.lat || !o.lng)
return
const dms2d = function(dms) {
// return (Math.floor(dms) + Math.floor(dms * 100) % 100 / 60 + Math.floor(dms * 10000) % 100 / (60 * 60)).toFixed(5)
// 度分秒の秒の小数点以下に対応する修正
return (Math.floor(dms) + Math.floor(dms * 100) % 100 / 60 + Math.floor(dms * 10000) % 100 / (60 * 60) + Math.floor(dms * 1000000) % 100 / (60 * 60 * 100)).toFixed(6)
}
o.lat = dms2d(o.lat)
o.lng = dms2d(o.lng)
}
window.onload = function() {
const map = initMap('mapid')
//map.setZoom(4)
const url = "https://fukuno.jig.jp/app/csv/data/ishibumi-data-281211.csv"
getJSON(url, function(csv) {
//dump(csv);
let lls = []
const icon = "icon-illustya-moses_jikkai.png"
let cnt = 0
for (let i = 1; i < csv.length; i++) {
const c = csv[i]
let d = {
num: c[0],
name: c[1],
address: c[2],
lat: c[3],
lng: c[4]
}
// convertJP2WGS(d)
// convertTokyo2WGS(d)
convertDMS2D(d)
if (!d.lat || !d.lng) {
//console.log("err: " + d.name + ", " + d.address + ", " + d.lat + ", " + d.lng)
cnt++
continue
} else {
//console.log("err: " + d.name + ", " + d.address + ", " + d.lat + ", " + d.lng)
}
//map.addIcon(d.lat, d.lng, d.name, icon, 64)
let name = "<a href=https://www2.city.kyoto.lg.jp/somu/rekishi/fm/ishibumi/html/" + d.num.toLowerCase() + ".html target=_blank rel=noopener>" + d.name + "</a>"
map.addIcon(d.lat, d.lng, [ d.num, name, d.address, d.lat + "," + d.lng ].join("<br>"))
lls.push([ d.lat, d.lng ])
}
//alert(cnt) // =85
//alert(lls.length) // =1470
map.fitBounds(lls)
setShowLL(map)
let watchid = null
gotohere.onclick = function() {
if (watchid)
navigator.geolocation.clearWatch(watchid)
watchid = navigator.geolocation.watchPosition(function(gpos) {
const pos = [ gpos.coords.latitude, gpos.coords.longitude ]
console.log(pos)
map.panTo(pos)
navigator.geolocation.clearWatch(watchid)
watchid = null
}, function() {
alert("現在位置に取得に失敗!")
})
}
})
}
const setShowLL = function(map) {
// センタークロス追加
const iconcenter = L.icon({
iconUrl: 'crosshairs.png',
iconRetinaUrl: 'crosshairs.png',
iconSize: [ 35, 35 ],
iconAnchor: [ 17, 17 ],
});
const crosshair = new L.marker(map.getCenter(), { icon: iconcenter, clickable:false })
crosshair.addTo(map);
map.on('move', function() {
crosshair.setLatLng(map.getCenter());
});
var showLL = function() {
var ll = map.getCenter()
if (window.tfll)
tfll.value = fixfloat(ll.lat, 6) + "," + fixfloat(ll.lng, 6)
}
showLL()
map.on("move", showLL)
}
</script>
<style>
body {
margin: 0;
font-family: sans-serif;
text-align: center;
background: white;
}
a {
color: gray !important;
}
h1 {
font-size: 3vh;
padding: .5vh;
margin: 0;
color: white;
background-color: #9cd;
}
#sub {
font-size: 4vw;
}
#mapid {
height: 70vh;
}
.leaflet-tile-container { /* 地図の色味変更 CSS3 filter */
x-filter: sepia(100%) brightness(95%); /* セピア */
x-filter: grayscale(100%) brightness(110%); /* 明るめグレースケール */
filter: hue-rotate(-10deg) saturate(70%) brightness(104%); /* いい感じの色? */
}
.leaflet-marker-pane > a {
word-break: break-all;
}
#debug {
text-align: left;
}
#tfll {
box-sizing: border-box;
text-align: center;
font-size: 120%;
width: 100%;
border: 1px solid gray;
}
.credit {
margin-top: 1vh;
font-size: 90%;
}
#gotohere {
background: orange;
color: white;
font-weight: bold;
padding: 1em;
margin: 0.5em;
}
</style>
</Head>
<body>
<h1>全1470個所 いしぶみマップ</h1>
<div id="mapid"></div>
<!--<input type=text id="tfll">-->
<button id=gotohere>現在位置へ移動</button>
<div class=credit>
App: <a href=https://fukuno.jig.jp/2437>全1470個所 いしぶみマップ</a> CC BY fukuno.jig.jp<br>
Data: <a href=https://data.city.kyoto.lg.jp/node/14455>CC BY いしぶみリスト | 京都市オープンデータポータルサイト</a><br>
Icon: <a href=https://www.irasutoya.com/2016/10/blog-post_315.html>モーセの十戒のイラスト | かわいいフリー素材集 いらすとや</a><br>
Lib: <a href=https://fukuno.jig.jp/2363>egmapjs</a> CC BY fukuno.jig.jp (<a href=https://github.com/code4fukui/egmapjs>src on GitHub</a>)<br>
</div>
</body>
</html>