-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.html
More file actions
248 lines (241 loc) · 8.68 KB
/
index.html
File metadata and controls
248 lines (241 loc) · 8.68 KB
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Maplat - Vite Dev Mode TEST</title>
<meta content="yes" name="apple-mobile-web-app-capable" />
<meta content="yes" name="mobile-web-app-capable" />
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<link rel="icon" type="image/png" href="parts/favicon.png" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/ol.css" />
<!-- Mapbox GL JS -->
<link href="https://api.tiles.mapbox.com/mapbox-gl-js/v1.6.1/mapbox-gl.css" rel="stylesheet" />
<!-- MapLibre GL JS -->
<link href="https://unpkg.com/[email protected]/dist/maplibre-gl.css" rel="stylesheet" />
<style>
.mainview {
position: absolute;
top: 5%;
bottom: 5%;
left: 5%;
right: 5%;
}
.button {
position: absolute;
top: 95%;
bottom: 0%;
left: 5%;
right: 5%;
}
</style>
<!-- Development mode: styles will be loaded by Vite -->
<!-- Production mode: uncomment the line below -->
<!-- <link href="./dist/maplat_core.css" rel="stylesheet" /> -->
</head>
<body>
<h1 style="position: absolute; top: 0; left: 0; z-index: 9999; background: red; color: white;">VITE TEST VERSION</h1>
<div class="mainview">
<div id="map_div"></div>
</div>
<div class="button">
<button id="show">showLayer(Main)</button>
<button id="hide">hideLayer(Main)</button>
<button id="clear">clearMarker(Main)</button>
<button id="move">moveMarker(Main)</button>
<button id="remove">removeMarker(Main)</button>
<button id="add2">addMarker(Main2)</button>
<button id="clear2">clearMarker(Main2)</button>
<button id="addMap">addMarker(Map)</button>
<button id="clearMap">clearMarker(Map)</button>
<button id="unSelect">unSelect</button>
<button id="showAll">showAll</button>
<button id="hideAll">hideAll</button>
<button id="morioka">盛岡城</button>
<button id="maplat">盛岡(Maplat)</button>
<button id="tms">盛岡(TMS)</button> <button id="osm">OSM</button>
<button id="gsi">地理院</button> <button id="mapbox">Mapbox</button>
<button id="maplibre">MapLibre</button>
<button id="map_remove">Remove Map</button>
</div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/ol.js"></script>
<script src="https://api.tiles.mapbox.com/mapbox-gl-js/v1.6.1/mapbox-gl.js"></script>
<script src="https://unpkg.com/[email protected]/dist/maplibre-gl.js"></script>
<!-- Development mode with Vite -->
<script type="module">
import { MaplatApp } from './src/index.ts';
window.addEventListener('DOMContentLoaded', async () => {
// For backward compatibility
window.MaplatApp = MaplatApp;
window.Maplat = MaplatApp;
var option = {
mapboxgl: mapboxgl,
maplibregl: maplibregl,
mapboxToken: "pk.eyJ1IjoicmVraXNoaWtva3VkbyIsImEiOiJjazRoMmF3dncwODU2M2ttdzI2aDVqYXVwIn0.8Hb9sekgjfck6Setxk5uVg",
startFrom: "morioka_ndl2",
restore: {
mapID: "morioka_ndl2"
}
};
var hashes = window.location.href
.slice(window.location.href.indexOf("?") + 1)
.split("&");
for (var i = 0; i < hashes.length; i++) {
const hash = hashes[i].split("=");
if (!hash[0]) continue;
if (hash[0] === "startFrom") continue;
option[hash[0]] =
hash[1] == "true" ? true : hash[1] == "false" ? false : hash[1];
}
MaplatApp.createObject(option).then(function (app) {
console.log(app);
window.__MAPLAT_APP__ = app;
console.log(app.currentMapInfo());
console.log(app.mapInfo("gsi"));
var moveFlag = false;
app.addEventListener("clickMarker", function (evt) {
app.selectMarker(evt.detail.namespaceID);
console.log(evt);
});
app.addEventListener("clickMap", function (evt) {
console.log(evt);
});
app.addLine({
lnglats: [
[141.151995, 39.701599],
[141.151137, 39.703736],
[141.1521671, 39.7090232]
],
stroke: {
color: "#ffcc33",
width: 2
}
});
app.addPoiLayer("main2");
app.addPoiLayer("morioka_ndl2#main2", {
icon: "parts_test/blue_marker.png",
selectedIcon: "parts_test/red_marker.png"
});
document.getElementById("show").addEventListener("click", function (e) {
app.showPoiLayer("main");
});
document.getElementById("hide").addEventListener("click", function (e) {
app.hidePoiLayer("main");
});
document
.getElementById("clear")
.addEventListener("click", function (e) {
app.clearMarker("main");
});
document.getElementById("move").addEventListener("click", function (e) {
var data;
if (moveFlag) {
data = { lnglat: [141.145358, 39.69862] };
} else {
data = { lnglat: [141.146534, 39.694758] };
}
moveFlag = !moveFlag;
app.updateMarker("main_1", data);
});
document
.getElementById("remove")
.addEventListener("click", function (e) {
app.removeMarker("main_2");
});
document.getElementById("add2").addEventListener("click", function (e) {
app.addMarker(
{
address: "岩手県盛岡市内丸1-42",
desc:
"寛延2年創建で当時の藩主南部利視が初代藩主南部信直の功績を称え社殿を建立し御霊を勧請したのが始まりとされている。",
icon: undefined,
image: "sakurayama_jinja.jpg",
lnglat: [141.151995, 39.701599],
name: "桜山神社",
selectedIcon: undefined,
start: 1749
},
"main2"
);
});
document
.getElementById("clear2")
.addEventListener("click", function (e) {
app.clearMarker("main2");
});
document
.getElementById("addMap")
.addEventListener("click", function (e) {
app.addMarker(
{
address: "岩手県盛岡市内丸1-37",
desc:
"南部(盛岡)藩南部氏の居城である。西部を流れる北上川と南東部を流れる中津川の合流地、現在の盛岡市中心部にあった花崗岩丘陵に築城された連郭式平山城。",
icon: undefined,
image: "moriokajo.jpg",
lnglat: [141.1501111, 39.69994722],
name: { ja: "盛岡城", en: "Morioka Castle" },
selectedIcon: undefined,
start: 1598
},
"morioka_ndl2#main2"
);
});
document
.getElementById("clearMap")
.addEventListener("click", function (e) {
app.clearMarker("morioka_ndl2#all");
});
document
.getElementById("unSelect")
.addEventListener("click", function (e) {
app.unselectMarker();
});
document
.getElementById("showAll")
.addEventListener("click", function (e) {
app.showAllMarkers();
});
document
.getElementById("hideAll")
.addEventListener("click", function (e) {
app.hideAllMarkers();
});
document
.getElementById("morioka")
.addEventListener("click", function (e) {
app.changeMap("morioka");
});
document
.getElementById("maplat")
.addEventListener("click", function (e) {
app.changeMap("morioka_ndl2");
});
document.getElementById("tms").addEventListener("click", function (e) {
app.changeMap("morioka_ndl_affine");
});
document.getElementById("osm").addEventListener("click", function (e) {
app.changeMap("osm");
});
document.getElementById("gsi").addEventListener("click", function (e) {
app.changeMap("gsi");
});
document
.getElementById("mapbox")
.addEventListener("click", function (e) {
app.changeMap("mapbox");
});
document
.getElementById("maplibre")
.addEventListener("click", function (e) {
app.changeMap("maplibre");
});
document
.getElementById("map_remove")
.addEventListener("click", function (e) {
app.remove();
});
});
}); // DOMContentLoaded
</script>
</body>
</html>