-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTheKarte.html
executable file
·366 lines (306 loc) · 12.1 KB
/
TheKarte.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
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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>TheKarte</title>
<link rel="icon" type="image/svg+xml" href="img/TheKarte-logo.svg" />
<link rel="icon" type="image/png" href="img/TheKarte-logo.png" sizes="96x96">
<style>
body {
margin: 0px;
overflow: hidden;
}
#initialLogo {
position: fixed;
padding: 0px;
top: 0px;
left: 0px;
width: 100%;
height: 100%;
background-image: url("img/TheKarte-logo-title.svg");
background-repeat: no-repeat;
background-position: center;
background-size: 30%;
background-color: white;
}
#logo {
position: absolute;
bottom: 1em;
right: 1em;
z-index: -1;
opacity: 0.3;
transition: z-index 1s;
animation-name: logoFadeIn;
animation-duration: 1.5s;
animation-delay: 2s;
animation-fill-mode: forwards;
}
#logo:hover {
opacity: 1;
transition: opacity 1s;
}
@keyframes logoFadeIn {
0% {
height: 0em;
z-index: -1;
}
100% {
height: 3em;
z-index: 1;
}
}
#theKarteMap {
width: 100%;
height: 100%;
position: absolute;
}
#theKarteMenuUI {
position: absolute;
bottom: 1em;
left: 50%;
transform: translateX(-50%);
z-index: -1;
padding-left: 1em;
padding-right: 1em;
line-height: 3em;
vertical-align: middle;
user-select: none;
color: rgba(0, 0, 0, 0.5);
background-color: rgba(255, 255, 255, 0.3);
border-radius: 1em;
/* This is a workaround as the cursor is otherwise text.*/
cursor: pointer;
animation-name: logoFadeIn;
animation-duration: 1.5s;
animation-delay: 2s;
animation-fill-mode: forwards;
}
#theKarteMenuUI:hover {
color: rgba(0, 0, 0, 1);
transition: color 0.2s;
}
#theKarteFeedback {
box-sizing: border-box;
width: 100%;
height: 100%;
position: absolute;
z-index: 1;
opacity: 1;
pointer-events: none;
}
@keyframes feedbackAnimation {
0% {
opacity: 0
}
50% {
opacity: 1
}
100% {
opacity: 0
}
}
.feedbackOk {
animation-name: feedbackAnimation;
animation-duration: 1s;
animation-fill-mode: forwards;
border: 0.25em solid;
border-image: radial-gradient(DeepSkyBlue, SkyBlue) 1;
}
.feedbackError {
animation-name: feedbackAnimation;
animation-duration: 1s;
animation-fill-mode: forwards;
border: 0.25em solid;
border-image: radial-gradient(DeepPink, Pink) 1;
}
</style>
<script src="dependencies/ol.js"></script>
<link rel="stylesheet" href="dependencies/ol.css">
<script src="src/ColorRGB.js"></script>
<script src="src/HelperExport.js"></script>
<script src="src/ImportHandler.js"></script>
<script src="src/HelperDataImportGeo.js"></script>
<script src="src/MenuActionAbstract.js"></script>
<script src="src/MenuActionDrop.js"></script>
<script src="src/MenuActionFeature.js"></script>
<script src="src/MenuActionExport.js"></script>
<script src="src/MenuActionHelp.js"></script>
<script src="src/MenuActionLayer.js"></script>
<script src="src/MenuActionStyle.js"></script>
<script src="src/MenuActionView.js"></script>
<script src="src/KeyboardMenu.js"></script>
<script src="src/StyleColorCreator.js"></script>
<script src="src/StyleCreator.js"></script>
<script src="src/StyleContainer.js"></script>
<script src="src/TheKarte.js"></script>
</head>
<script>
//Print version and other information
var versionInformation =
"TheKarte" +
"\n===\n" +
"Version: package.json:version\n" +
"Version (GIT): git.revision\n" +
"Homepage: package.json:homepage\n" +
"License: package.json:license\n";
console.log(versionInformation);
console.log("package.json:description\n\n");
//Configure theKarte incl. keyboard-based menu.
var theKarte = undefined;
theKarte = new TheKarte(
new StyleCreator(), new StyleColorCreator()
);
const importHandler = new ImportHandler(theKarte);
const defaultTileSource = new ol.source.OSM();
const keyboardMenu = new KeyboardMenu(
"g",
"v",
new Map([
//show menu structure
['h', new MenuActionHelp(theKarte)],
//Insert
['a', new Map([
['a', new MenuActionLayerAdd(theKarte)],
['s', new MenuActionFeatureAdd(theKarte, 'Point')],
['d', new MenuActionFeatureAdd(theKarte, 'Polygon')],
['f', new MenuActionFeatureAdd(theKarte, 'Circle')],
['q', new MenuActionFeatureAdd(theKarte, 'LineString')]
])],
//Delete
['s', new Map([
['a', new MenuActionLayerDelete(theKarte)],
['s', new MenuActionFeatureDelete(theKarte)]
])],
//Select and modify
['d', new Map([
['a', new MenuActionLayerSelect(theKarte)],
['1', new MenuActionLayerSelectNow(theKarte, 1)],
['2', new MenuActionLayerSelectNow(theKarte, 2)],
['3', new MenuActionLayerSelectNow(theKarte, 3)],
['4', new MenuActionLayerSelectNow(theKarte, 4)],
['5', new MenuActionLayerSelectNow(theKarte, 5)],
['s', new MenuActionFeatureModify(theKarte)]
])],
//Style
['f', new Map([
['a', new MenuActionViewExtent(theKarte)],
['s', new Map([
['d', new MenuActionViewClippingLayer(theKarte, true)],
['f', new MenuActionViewClippingLayer(theKarte, false)]
])],
['d', new Map([
['d', new MenuActionViewStyleImageScale(theKarte, 0.1)],
['f', new MenuActionViewStyleImageScale(theKarte, -0.1)],
])],
['f', new MenuActionViewClusterToggle(theKarte, 40)]
])],
//Map style: set tile layer
['q', new Map([
['a', new MenuActionViewTile(theKarte, defaultTileSource)],
['s', new MenuActionViewTile(theKarte, new ol.source.XYZ({
attributions: 'Tiles © <a href="https://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer">ArcGIS</a>',
url: 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}'
}))],
['d', new MenuActionViewTile(theKarte, new ol.source.TileImage({
attributions: 'Tiles © <a href="https://www.google.com/permissions/geoguidelines/">Google</a>',
url: 'http://maps.google.com/maps/vt?pb=!1m5!1m4!1i{z}!2i{x}!3i{y}!4i256!2m3!1e0!2sm!3i375060738!3m9!2spl!3sUS!5e18!12m1!1e47!12m3!1e37!2m1!1ssmartmaps!4e0'
}))],
['f', new MenuActionViewTile(theKarte, new ol.source.Stamen({
layer: 'toner'
}))]
])],
//Export
['w', new Map([
['a', new Map([
['d', new MenuActionExportKML(theKarte, true)],
['f', new MenuActionExportKML(theKarte, false)]
])],
['s', new Map([
['d', new MenuActionFeatureFilter(theKarte, false)],
['f', new MenuActionFeatureFilter(theKarte, true)]
])],
['d', new MenuActionExportPNG(theKarte)]
])],
//Drop mode
['e', new Map([
['d', new MenuActionDrop(theKarte, importHandler, 'geo')],
['f', new MenuActionDrop(theKarte, importHandler, 'style')],
])],
//Render mode
['r', new Map([
['d', new MenuActionViewPerformance(theKarte, true)],
['f', new MenuActionViewPerformance(theKarte, false)]
])]
])
);
//Print menu to console
console.log(keyboardMenu.toString());
</script>
<script>
function onLoaded() {
let logElement = document.getElementById("logElement");
if (theKarte === undefined) {
//Some resources (JavaScript files) could not be loaded.
logElement.innerHTML += "<br><i>One or more resources failed to load:<\/i> Please check in the brower's developer console.";
return;
}
logElement.innerHTML += "<br>All resources were loaded.";
try {
//Setup UI if all resources were loaded.
logElement.innerHTML += "<br>Starting TheKarte...";
//Setup menuUI
const theKarte_MenuUIElement = document.createElement("a");
theKarte_MenuUIElement.id = "theKarteMenuUI";
theKarte_MenuUIElement.onclick = function() {
new MenuActionHelp(theKarte).start();
};
document.body.append(theKarte_MenuUIElement);
const keyboardMenuNavigationCallback = function(keyboardMenu) {
theKarte_MenuUIElement.innerText = keyboardMenu.formatStack();
};
keyboardMenu.setNavigationChangedCallback(keyboardMenuNavigationCallback);
//Prepare userFeedback
const theKarte_FeedbackElement = document.createElement("div");
theKarte_FeedbackElement.id = "theKarteFeedback";
document.body.append(theKarte_FeedbackElement);
const userFeedbackCallback = function(isOk) {
theKarte_FeedbackElement.classList.remove("feedbackOk");
theKarte_FeedbackElement.classList.remove("feedbackError");
void theKarte_FeedbackElement.offsetWidth;
theKarte_FeedbackElement.className = isOk ? "feedbackOk" : "feedbackError";
}.bind(this);
logElement.parentNode.removeChild(logElement);
//Create TheKarte
const theKarte_MapElement = document.createElement("div");
theKarte_MapElement.id = "theKarteMap";
document.body.append(theKarte_MapElement);
theKarte.setup(keyboardMenu, importHandler, userFeedbackCallback, theKarte_MapElement, window, document.body);
theKarte.setTileSource(defaultTileSource);
document.getElementById("logo").parentElement.title = versionInformation;
//Start Autopilot
let autopilotCommand = window.location.search.substr(1);
if (autopilotCommand.length > 0) {
theKarte.autopilot(autopilotCommand.split('&'));
}
window.onbeforeunload = function(event) {
const text = "Do want to reload/close TheKarte? All data will be lost.";
event.returnValue = text;
return text;
};
} catch (e) {
//Something went wrong...
logElement.innerHTML += "<br><i>Failed to start TheKarte:<\/i> Please check in the brower's developer console.";
}
}
</script>
</head>
<body onload="onLoaded()">
<p id="logElement" style="text-align:center">
TheKarte is loading...
</p>
<div id="initialLogo"></div>
<a href="package.json:homepage" target="_blank">
<img id="logo" src="img/TheKarte-logo.svg"></img>
</a>
</body>
</html>