-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
51 lines (49 loc) · 1.34 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
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no"/>
<title>ab</title>
<link rel="stylesheet" href="maplibre-gl.css" crossorigin="anonymous">
<script src="maplibre-gl.js" crossorigin="anonymous"></script>
<script src="https://unpkg.com/[email protected]/dist/index.js"></script>
<style>
body { margin: 0; }
#map { height:100%; width:100%; }
#info { position: absolute; top: 0; right: 0; overflow: auto;
margin: 0px auto; border: none; background: rgba(255, 255, 255, 0.8); }
</style>
</head>
<body>
<div id="map"></div>
<pre id="info"></pre>
<script type="text/javascript">
let protocol = new pmtiles.Protocol()
maplibregl.addProtocol("pmtiles", protocol.tile)
const map = new maplibregl.Map({
center: [140.0896, 36.08303],
zoom: 14.02,
maxZoom: 20,
container: 'map',
hash: true,
style: 'style.json'
})
map.on('mousemove', e => {
let fs = map.queryRenderedFeatures(e.point, { layers: ['fude'] })
let j = '-'
if (fs.length == 0) {
} else {
let a = []
for(let f of fs) {
let p = f.properties
let pr = (k) => {
return !p[k] ? '' : p[k]
}
a.push(pr('市区町村名') + pr('大字名') + pr('丁目名') + pr('小字名') + pr('地番'))
}
j = a.join('; ')
}
document.getElementById('info').innerHTML = j
})
</script>
</body>
</html>