-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.html
145 lines (139 loc) · 5.36 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
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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Retroscope</title>
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0" />
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" />
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
<script src="https://unpkg.com/[email protected]/leaflet-hash.js"></script>
<script src="https://frogcat.github.io/leaflet-tilelayer-mask/leaflet-tilelayer-mask.js"></script>
<script>
var config = {
gsi: {
urlTemplate: "https://cyberjapandata.gsi.go.jp/xyz/{$1=std}/{z}/{x}/{y}.{$2=png}",
options: {
attribution: "<a href='http://maps.gsi.go.jp/development/ichiran.html'>地理院タイル</a>"
}
},
mw: {
urlTemplate: "http://mapwarper.net/maps/tile/{$1=20822}/{z}/{x}/{y}.png",
options: {
attribution: "<a href='http://mapwarper.net/maps/{$1}'>Map Warper</a>"
}
},
mwjp: {
urlTemplate: "http://mapwarper.h-gis.jp/maps/tile/{$1=1605}/{z}/{x}/{y}.png",
options: {
attribution: "<a href='https://mapwarper.h-gis.jp/maps/{$1}'>日本版 Map Warper</a>"
}
},
nypl: {
urlTemplate: "http://maps.nypl.org/warper/maps/tile/{$1}/{z}/{x}/{y}.png",
options: {
attribution: "<a href='http://maps.nypl.org/warper/maps/{$1}'>NYPL Map Warper</a>"
}
},
osm: {
urlTemplate: "http://{s}.tile.osm.org/{z}/{x}/{y}.png",
options: {
attribution: "© <a href='http://osm.org/copyright'>OpenStreetMap</a> contributors"
}
},
habs: {
urlTemplate: "https://habs.dc.affrc.go.jp/rapid16/{z}/{x}/{y}.png",
options: {
attribution: "<a href='http://habs.dc.affrc.go.jp/'>歴史的農業環境閲覧システム(NIAES)</a>",
minZoom: 1,
maxNativeZoom: 17,
tms: true
}
},
nls: {
urlTemplate: "https://nls-1.tileserver.com/nls/{z}/{x}/{y}.jpg",
options: {
attribution: "Historical maps from 1919-47 <a href='http://geo.nls.uk/maps/api/'>NLS Maps API</a>",
minZoom: 1,
maxNativeZoom: 17
}
},
kjm: {
urlTemplate: "https://sv53.wadax.ne.jp/~ktgis-net/kjmapw/kjtilemap/{$1}/{$2}/{z}/{x}/{y}.png",
options: {
attribution: "<a href='http://ktgis.net/kjmapw/'>今昔マップ on the web</a>",
tms: true
}
},
hinata: {
urlTemplate: "https://mtile.pref.miyazaki.lg.jp/tile/{$1}/{$2}/{z}/{x}/{y}.png",
options: {
attribution: "<a href='https://hgis.pref.miyazaki.lg.jp/hinata/'>ひなたGIS</a>",
tms: true
}
},
bosai: {
urlTemplate: "http://maptile01.bosai.go.jp/{$1}/xyz/{z}/{x}/{y}.png",
options: {
attribution: "<a href='http://ecom-plat.jp/suigai-chikei/index.php'>水害地形分類図デジタルアーカイブ</a>"
}
}
};
</script>
</head>
<body>
<div id="map" style="position:absolute;top:0;left:0;right:0;bottom:0;display:none;"></div>
<div id="menu">
<h1>Retroscope</h1>
<h2>examples</h2>
<ul>
<li><a href="?gsi=ort,jpg&habs#15/35.6707/139.7852">迅速測図 on 地理院地図(オルソ)</a></li>
<li><a href="?osm&gsi=ort,jpg#15/35.6707/139.7852">地理院地図(オルソ) on OpenStreetMap</a></li>
<li><a href="?mw=20822&osm#11/35.3275/139.8542">osm on mapwarper</a></li>
<li><a href="?mw=20822&gsi=pale#12/35.0660/140.0735">地理院地図(淡色地図) on mapwarper</a></li>
<li><a href="?gsi=ort_riku10&gsi=ort_USA10#16/35.6701/139.6974">戦前と戦後の代々木公園周辺</a></li>
</ul>
</div>
<script>
if (location.search === "" && location.hash.match(/^#[0-9]+\/[0-9.]+\/[0-9.]+$/))
location.href = "?gsi=ort,jpg&habs" + location.hash;
var defs = location.search.replace("?", "").split("&").map(function(a) {
var tokens = a.split(/[=,]/);
var json = config[tokens[0]];
if (!json) return null;
for (var i = 1; i < 10; i++) {
if (json.urlTemplate.match(new RegExp("{\\$" + i + "=([^}]+)}")))
if (!tokens[i]) tokens[i] = RegExp.$1;
}
var tmpl = JSON.stringify(json);
for (var i = 1; i < tokens.length; i++)
tmpl = tmpl.replace(new RegExp("{\\$" + i + "[^}]*}", "g"), tokens[i]);
return JSON.parse(tmpl);
});
if (defs[0] && defs[1]) {
document.getElementById("map").style.display = "block";
var map = L.map("map", L.extend({
zoom: 15,
center: [35.6707, 139.7852]
}, L.Hash.parseHash(location.hash)));
var bg = L.tileLayer(defs[0].urlTemplate, defs[0].options).addTo(map);
var fg = L.tileLayer.mask(defs[1].urlTemplate, defs[1].options).addTo(map);
map.zoomControl.setPosition("bottomright");
map.attributionControl.addAttribution("<a href='https://github.com/frogcat/retroscope'>fork me on GitHub</a>");
L.hash(map);
if (L.Browser.mobile) {
var cp = null;
map.on("click", function(event) {
cp = event.containerPoint;
fg.setCenter(cp);
}).on("move", function() {
if (cp) fg.setCenter(cp);
});
} else {
map.on("mousemove", function(event) {
fg.setCenter(event.containerPoint);
});
}
}
</script>
</body>
</html>