-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
58 lines (55 loc) · 2.38 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Leaflet.TileGeoJSON Example</title>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" />
<style>
* {margin:0;padding:0;box-sizing:border-box}
#contents{height:100vh;width:100vw;position:relative}
#desc{position:absolute;left:10px;bottom:10px;height:160px;width:400px;border-radius:3px;background-color:#fff;z-index:100000;box-shadow:3px 3px 3px rgba(0,0,0,0.3);padding:20px;}
#desc h1{font-size:16px;margin-bottom:10px}
</style>
</head>
<body>
<div id="contents"></div>
<div id="desc">
<h1>Leaflet.TileGeoJSON</h1>
<p>This is an demo page (<a href="https://github.com/zeroyonichihachi/Leaflet.TileGeoJSON/blob/gh-pages/index.html">source</a>) for the <a href="https://github.com/zeroyonichihachi/Leaflet.TileGeoJSON">Leaflet.TileGeoJSON</a> which is a <a href="https://leafletjs.com/">Leaflet</a> (v1.4 or above) plugin, handles/shows the tile splitted GeoJSON files.</p>
</div>
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
<script src="dist/Leaflet.TileGeoJSON.min.js"></script>
<script>
const map = L.map('contents', {
center: [35.301279, 139.481001],
zoom: 14,
minZoom: 14,
maxZoom: 16,
});
L.tileLayer('http://cyberjapandata.gsi.go.jp/xyz/std/{z}/{x}/{y}.png', {
attribution: '<a href="http://maps.gsi.go.jp/development/ichiran.html" target="_blank">Geospatial Information Authority of Japan</a>',
}).addTo(map);
// Construct TileGeoJSON (layer instance).
L.tileGeoJSON(
// template URL for tiles.
'https://cyberjapandata.gsi.go.jp/xyz/experimental_landformclassification2/{z}/{x}/{y}.geojson',
// options for L.GridLayer (https://leafletjs.com/reference-1.4.0.html#gridlayer).
{},
// options for L.GeoJSON (layer class) (https://leafletjs.com/reference-1.4.0.html#geojson).
{
style: feature => ({
weight: 2,
fill: true,
fillOpacity: 0.5,
clickable: true,
color: '#0000FF',
fillColor: '#0000FF',
}),
onEachFeature: (feature, layer) => {
layer.bindPopup(`<table><tr><th>CODE:</th><td>${feature.properties.code}</td></tr></table>`);
},
}
).addTo(map); // TileGeoJSON instance can be added to map like as the ordinal leaflet layers.
</script>
</body>
</html>