Sebastiankay commited on
Commit
0a2717a
·
verified ·
1 Parent(s): 7ba87ed

Update templates/map.html

Browse files
Files changed (1) hide show
  1. templates/map.html +1157 -1157
templates/map.html CHANGED
@@ -1,1158 +1,1158 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
-
4
- <head>
5
- <meta charset="UTF-8" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
-
8
- <!--title>Tarkov Map with friends</title-->
9
- <title>{{ maps[0].name }} | Map with friends</title>
10
- <link rel="icon" type="image/x-icon" href="/static/favicon.ico" />
11
- <link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css" />
12
- <!--link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet-groupedlayercontrol/0.6.1/leaflet.groupedlayercontrol.css"/-->
13
- <script src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js"></script>
14
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css" />
15
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@1.0.2/css/bulma.min.css" />
16
- <link rel="stylesheet" href="/static/style.css" />
17
- </head>
18
-
19
- <body>
20
- <nav class="navbar is-fixed-top" role="navigation" aria-label="main navigation">
21
- <div class="navbar-brand">
22
- <a class="navbar-item" href="https://bulma.io">
23
- <svg width="640" height="160" viewBox="0 0 640 160" fill="none" xmlns="http://www.w3.org/2000/svg">
24
- <path fill-rule="evenodd" clip-rule="evenodd" d="M170 132.571V27.5908C170 25.5451 170.915 23.93 172.746 22.7456C174.576 21.5612 176.729 20.969 179.206 20.969H210.377C232.019 20.969 242.84 30.4441 242.84 49.3943C242.84 62.5303 238.264 71.0902 229.112 75.074C234.603 77.2275 238.748 80.2692 241.548 84.1992C244.347 88.1292 245.747 93.8627 245.747 101.4V104.791C245.747 116.743 242.84 125.437 237.026 130.875C231.211 136.312 223.351 139.031 213.445 139.031H179.206C176.514 139.031 174.307 138.385 172.584 137.093C170.861 135.801 170 134.293 170 132.571ZM190.834 120.619H209.085C219.529 120.619 224.751 114.751 224.751 103.015V100.431C224.751 94.401 223.432 90.0404 220.794 87.3486C218.156 84.6568 214.253 83.3109 209.085 83.3109H190.834V120.619ZM190.834 66.8371H208.923C213.122 66.8371 216.326 65.5989 218.533 63.1225C220.74 60.646 221.844 57.2544 221.844 52.9475C221.844 48.7483 220.686 45.4374 218.371 43.0148C216.057 40.5922 212.853 39.3809 208.762 39.3809H190.834V66.8371ZM260.283 103.015V27.4293C260.283 25.2759 261.306 23.6608 263.351 22.5841C265.397 21.5074 267.873 20.969 270.781 20.969C273.688 20.969 276.164 21.5074 278.21 22.5841C280.256 23.6608 281.279 25.2759 281.279 27.4293V103.015C281.279 115.397 287.2 121.588 299.044 121.588C310.888 121.588 316.81 115.397 316.81 103.015V27.4293C316.81 25.2759 317.833 23.6608 319.879 22.5841C321.925 21.5074 324.401 20.969 327.308 20.969C330.215 20.969 332.692 21.5074 334.738 22.5841C336.783 23.6608 337.806 25.2759 337.806 27.4293V103.015C337.806 115.72 334.28 125.061 327.227 131.036C320.175 137.012 310.781 140 299.044 140C287.308 140 277.914 137.039 270.861 131.117C263.809 125.195 260.283 115.828 260.283 103.015ZM356.703 132.409V27.4293C356.703 25.2759 357.725 23.6608 359.771 22.5841C361.817 21.5074 364.293 20.969 367.201 20.969C370.108 20.969 372.584 21.5074 374.63 22.5841C376.676 23.6608 377.699 25.2759 377.699 27.4293V120.619H417.106C419.044 120.619 420.579 121.534 421.709 123.365C422.84 125.195 423.405 127.349 423.405 129.825C423.405 132.301 422.84 134.455 421.709 136.285C420.579 138.116 419.044 139.031 417.106 139.031H365.908C363.432 139.031 361.279 138.439 359.448 137.254C357.618 136.07 356.703 134.455 356.703 132.409ZM434.872 132.409V31.467C434.872 27.9138 435.868 25.2759 437.86 23.5532C439.852 21.8304 442.355 20.969 445.37 20.969C449.354 20.969 452.423 21.6689 454.576 23.0686C456.729 24.4684 459.098 27.4832 461.682 32.1131L481.548 68.2907L501.413 32.1131C503.997 27.4832 506.393 24.4684 508.6 23.0686C510.808 21.6689 513.903 20.969 517.887 20.969C520.902 20.969 523.405 21.8304 525.397 23.5532C527.389 25.2759 528.385 27.9138 528.385 31.467V132.409C528.385 134.455 527.335 136.07 525.236 137.254C523.136 138.439 520.686 139.031 517.887 139.031C514.98 139.031 512.503 138.439 510.458 137.254C508.412 136.07 507.389 134.455 507.389 132.409V62.961L488.493 96.5545C486.985 99.354 484.616 100.754 481.386 100.754C478.264 100.754 475.949 99.354 474.441 96.5545L455.868 61.6689V132.409C455.868 134.455 454.818 136.07 452.719 137.254C450.619 138.439 448.17 139.031 445.37 139.031C442.463 139.031 439.987 138.439 437.941 137.254C435.895 136.07 434.872 134.455 434.872 132.409ZM539.529 130.31C539.529 130.094 539.637 129.556 539.852 128.694L571.023 27.1063C571.669 24.8452 573.257 23.0956 575.787 21.8573C578.318 20.6191 581.198 20 584.428 20C587.658 20 590.565 20.6191 593.149 21.8573C595.734 23.0956 597.349 24.8452 597.995 27.1063L629.166 128.694C629.381 129.556 629.489 130.094 629.489 130.31C629.489 132.678 628.035 134.724 625.128 136.447C622.221 138.17 619.26 139.031 616.245 139.031C612.261 139.031 609.892 137.631 609.139 134.832L603.001 113.351H566.016L559.879 134.832C559.125 137.631 556.756 139.031 552.773 139.031C549.65 139.031 546.662 138.197 543.809 136.528C540.956 134.859 539.529 132.786 539.529 130.31ZM570.377 96.8775H598.479L584.428 47.2948L570.377 96.8775Z" fill="black" class="bd-svg-black" />
25
- <path fill-rule="evenodd" clip-rule="evenodd" d="M0 110L10 40L50 0L100 50L70 80L110 120L50 160L0 110Z" fill="#00D1B2" />
26
- </svg>
27
-
28
- </a>
29
-
30
- <a role="button" class="navbar-burger" aria-label="menu" aria-expanded="false" data-target="navbarBasicExample">
31
- <span aria-hidden="true"></span>
32
- <span aria-hidden="true"></span>
33
- <span aria-hidden="true"></span>
34
- <span aria-hidden="true"></span>
35
- </a>
36
- </div>
37
-
38
- <div id="navbarBasicExample" class="navbar-menu">
39
- <div class="navbar-start">
40
- <a class="navbar-item">
41
- Home
42
- </a>
43
- <div class="navbar-item has-dropdown is-hoverable">
44
- <a class="navbar-link">Maps</a>
45
- <div class="navbar-dropdown is-boxed">
46
- <a href="/map/woods" class="navbar-item">Woods</a>
47
- <a href="/map/shoreline" class="navbar-item">Shoreline</a>
48
- <a href="/map/lighthouse" class="navbar-item">Lighthouse</a>
49
- <a href="/map/customs" class="navbar-item">Customs</a>
50
- <a href="/map/interchange" class="navbar-item">Interchange</a>
51
- <a href="/map/streets-of-tarkov" class="navbar-item">Streets of Tarkov</a>
52
- <a href="/map/ground-zero" class="navbar-item">Ground Zero</a>
53
- <a href="/map/reserve" class="navbar-item">Reserve</a>
54
- <a href="/map/factory" class="navbar-item">Factory</a>
55
- </div>
56
- </div>
57
- </div>
58
-
59
- <div class="navbar-end">
60
- <div class="navbar-item">
61
- <button class="button is-dark js-modal-trigger" data-target="settings-modal">
62
- <span class="icon is-small">
63
- <i class="fas fa-cog"></i>
64
- </span>
65
- </button>
66
- </div>
67
- </div>
68
- </div>
69
- </nav>
70
-
71
- <div id="map"></div>
72
-
73
-
74
- <div id="settings-modal" class="modal">
75
- <div class="modal-background"></div>
76
-
77
- <div class="modal-content container">
78
- <div class="box">
79
- <section class="hero">
80
- <div class="hero-body">
81
- <p class="title has-text-weight-bold">EINSTELLUNGEN</p>
82
- <hr class="title-line">
83
- <p class="subtitle">Subtitle</p>
84
- </div>
85
- </section>
86
- <!-- Your content -->
87
- <section class="section">
88
- <div class="content">
89
- <p>
90
- Hier die Einstellungen basierend auf der config.ini file.
91
-
92
- {#
93
- [mainconfig]
94
- eft_log_older_path = E:/Battlestate Games/Escape from Tarkov/Logs/
95
- eft_screenshots_folder_path = C:/Users/Sebastian/Documents/Escape from Tarkov/Screenshots/
96
- delete_screenshots = True
97
- eft_show_exits_key = o
98
- eft_take_screenshot_key = del #}
99
- </p>
100
- </div>
101
- </section>
102
- </div>
103
- </div>
104
-
105
- <button class="modal-close is-large" aria-label="close"></button>
106
- </div>
107
-
108
-
109
- <script src="/static/js/leaflet.controlGroupedlayer.js"></script>
110
- <script src="/static/js/leaflet.controlCoordinates.js"></script>
111
- <script>
112
- // GLOBAL VARIABLE TO HOLD THE CURRENT MARKER
113
- let currentMarker = null;
114
- const client_id = Date.now()
115
- const mapData = {{ maps[0] | tojson }}
116
- console.info(mapData)
117
- //const transform = [0.1855, 113.1, 0.1855, 167.8]
118
- const transform = mapData.transform
119
- const bounds = mapData.bounds
120
- const svgBounds = mapData.svgBounds ? mapData.svgBounds : bounds
121
- const coordinateRotation = mapData.coordinateRotation ? mapData.coordinateRotation : 0
122
- const svgPath = mapData.svgPath
123
- const imageUrl = mapData.svgPath
124
- const minZoom = mapData.minZoom ? mapData.minZoom : 1
125
- const maxZoom = mapData.maxZoom ? mapData.maxZoom : 6
126
- const showElevation = false;
127
- const showStaticMarkers = false
128
-
129
- let currentZoom = 3;
130
-
131
-
132
- const ws = new WebSocket(`ws://localhost:8000/${client_id}`)
133
- ws.onmessage = function (event) {
134
- console.log(event.data);
135
- const data = JSON.parse(event.data);
136
- if (data.type === "coordinates") {
137
- const parsedData = data.data;
138
- localStorage.setItem("last_marker", JSON.stringify(parsedData));
139
- loadLocalData();
140
- }
141
- if (data.type === "location_map") {
142
- const map_name = data.data.map.toLowerCase().replaceAll(" ", "-")
143
- localStorage.setItem("last_map_name", data.data.map.toLowerCase().replaceAll(" ", "-"));
144
- localStorage.removeItem("last_marker")
145
- if (!location.pathname.includes(map_name)) location.pathname = `/map/${map_name}`
146
- else location.reload()
147
- }
148
- if (data.type == "new_rade_data") {
149
- console.log(data.data)
150
- const parsedData = JSON.parse(data.data);
151
- localStorage.setItem("rade_data", JSON.stringify(parsedData));
152
- loadLocalData();
153
- }
154
- };
155
-
156
- ws.onopen = function (event) {
157
- console.log(JSON.stringify({ type: "test_msg", data: "Test Message" }));
158
- ws.send(JSON.stringify({ type: "test_msg", data: "Test Message" }));
159
- };
160
-
161
-
162
- function loadLocalData() {
163
-
164
- const map_name = localStorage.getItem("last_map_name")
165
- if (map_name) {
166
- if (!location.pathname.includes(map_name)) localStorage.removeItem("last_marker")
167
- } else localStorage.removeItem("last_marker")
168
-
169
- const markerData = JSON.parse(localStorage.getItem("last_marker"))
170
- console.log(markerData)
171
- if (markerData) {
172
- // Alten Marker entfernen
173
- if (currentMarker) {
174
- map.removeLayer(currentMarker);
175
- currentMarker = null;
176
- }
177
- // Neuen Marker hinzufügen
178
- addMarker(markerData.x, markerData.y, markerData.z, markerData.timestamp, markerData.preview ? markerData.preview : false);
179
- }
180
-
181
- const radeData = localStorage.getItem("rade_data");
182
- if (radeData) {
183
- const parsedData = JSON.parse(radeData);
184
- // Process the loaded radeData as needed
185
- console.log(parsedData);
186
-
187
- if (parseInt(parsedData.rade_end_time) > Math.floor(new Date().getTime() / 1000.0)) {
188
- // Rade is not over yet
189
- console.log("Rade is not over yet")
190
-
191
- const new_html = `
192
- <div class="rade-time"><i class="fa-solid fa-door-open"></i> <h3 id="rade_time_remain" data-seconds="${parseInt(parsedData.rade_end_time) - Math.floor(new Date().getTime() / 1000.0)}" data-rade-end="${parsedData.rade_end_time}" data-rade-start="${parsedData.rade_start_time}" class="rade-time-remain">${parsedData.remaining_time}</h3></div>
193
- <ul>
194
- ${parsedData.extraction_exit_names.map(name => `<li><span class="tag exit">EXIT</span> ${name}</li>`).join('')}
195
- ${parsedData.extraction_transit_names.map(name => `<li><span class="tag transit">TRANSIT</span> ${name.replaceAll("Transit ", "")}</li>`).join('')}
196
- </ul>
197
- `
198
- addNewRadeData(new_html)
199
- } else console.log("Rade is over")
200
- }
201
-
202
-
203
- };
204
-
205
- const images = {
206
- 'container_bank-cash-register': 'container_cash-register',
207
- 'container_bank-safe': 'container_safe',
208
- 'container_buried-barrel-cache': 'container_buried-barrel-cache',
209
- 'container_cash-register': 'container_cash-register',
210
- 'container_cash-register-tar2-2': 'container_cash-register',
211
- 'container_dead-civilian': 'container_dead-scav',
212
- 'container_dead-scav': 'container_dead-scav',
213
- 'container_festive-airdrop-supply-crate': 'container_festive-airdrop-supply-crate',
214
- 'container_pmc-body': 'container_dead-scav',
215
- 'container_civilian-body': 'container_dead-scav',
216
- 'container_drawer': 'container_drawer',
217
- 'container_duffle-bag': 'container_duffle-bag',
218
- 'container_grenade-box': 'container_grenade-box',
219
- 'container_ground-cache': 'container_ground-cache',
220
- 'container_jacket': 'container_jacket',
221
- 'container_lab-technician-body': 'container_dead-scav',
222
- 'container_medbag-smu06': 'container_medbag-smu06',
223
- 'container_medcase': 'container_medcase',
224
- 'container_medical-supply-crate': 'container_crate',
225
- 'container_pc-block': 'container_pc-block',
226
- 'container_plastic-suitcase': 'container_plastic-suitcase',
227
- 'container_ration-supply-crate': 'container_crate',
228
- 'container_safe': 'container_safe',
229
- 'container_scav-body': 'container_dead-scav',
230
- 'container_shturmans-stash': 'container_weapon-box',
231
- 'container_technical-supply-crate': 'container_crate',
232
- 'container_toolbox': 'container_toolbox',
233
- 'container_weapon-box': 'container_weapon-box',
234
- 'container_wooden-ammo-box': 'container_wooden-ammo-box',
235
- 'container_wooden-crate': 'container_wooden-crate',
236
- 'extract_pmc': 'extract_pmc',
237
- 'extract_scav': 'extract_scav',
238
- 'extract_shared': 'extract_shared',
239
- 'extract_transit': 'extract_transit',
240
- 'hazard': 'hazard',
241
- 'hazard_mortar': 'hazard_mortar',
242
- 'hazard_minefield': 'hazard',
243
- 'hazard_sniper': 'hazard',
244
- 'key': 'key',
245
- 'lock': 'lock',
246
- 'loose_loot': 'loose_loot',
247
- 'quest_item': 'quest_item',
248
- 'quest_objective': 'quest_objective',
249
- 'spawn_sniper_scav': 'spawn_sniper_scav',
250
- 'spawn_bloodhound': 'spawn_bloodhound',
251
- 'spawn_boss': 'spawn_boss',
252
- 'spawn_cultist-priest': 'spawn_cultist-priest',
253
- 'spawn_pmc': 'spawn_pmc',
254
- 'spawn_rogue': 'spawn_rogue',
255
- 'spawn_scav': 'spawn_scav',
256
- 'stationarygun': 'stationarygun',
257
- 'switch': 'switch',
258
- };
259
-
260
- const categories = {
261
- 'extract_pmc': 'PMC',
262
- 'extract_shared': 'Shared',
263
- 'extract_scav': 'Scav',
264
- 'extract_transit': 'Transit',
265
- 'spawn_sniper_scav': 'Sniper Scav',
266
- 'spawn_pmc': 'PMC',
267
- 'spawn_scav': 'Scav',
268
- 'spawn_boss': 'Boss',
269
- 'quest_item': 'Item',
270
- 'quest_objective': 'Objective',
271
- 'lock': 'Locks',
272
- 'lever': 'Lever',
273
- 'stationarygun': 'Stationary Gun',
274
- 'switch': 'Switch',
275
- 'place-names': 'Place Names',
276
- };
277
-
278
- function getCRS(transform) {
279
- let scaleX = 1;
280
- let scaleY = 1;
281
- let marginX = 0;
282
- let marginY = 0;
283
- if (transform) {
284
- scaleX = transform[0];
285
- scaleY = transform[2] * -1;
286
- marginX = transform[1];
287
- marginY = transform[3];
288
- }
289
- return L.extend({}, L.CRS.Simple, {
290
- transformation: new L.Transformation(scaleX, marginX, scaleY, marginY),
291
- projection: L.extend({}, L.Projection.LonLat, {
292
- project: latLng => {
293
- return L.Projection.LonLat.project(applyRotation(latLng, coordinateRotation));
294
- },
295
- unproject: point => {
296
- return applyRotation(L.Projection.LonLat.unproject(point), coordinateRotation * -1);
297
- },
298
- }),
299
- });
300
- }
301
-
302
- function applyRotation(latLng, rotation) {
303
- if (!latLng.lng && !latLng.lat) {
304
- return L.latLng(0, 0);
305
- }
306
- if (!rotation) {
307
- return latLng;
308
- }
309
-
310
- const angleInRadians = (rotation * Math.PI) / 180;
311
- const cosAngle = Math.cos(angleInRadians);
312
- const sinAngle = Math.sin(angleInRadians);
313
-
314
- const { lng: x, lat: y } = latLng;
315
- const rotatedX = x * cosAngle - y * sinAngle;
316
- const rotatedY = x * sinAngle + y * cosAngle;
317
- return L.latLng(rotatedY, rotatedX);
318
- }
319
-
320
- function pos(position) {
321
- return [position.z, position.x];
322
- }
323
-
324
- function addElevation(item, popup) {
325
- if (!showElevation) {
326
- return;
327
- }
328
- const elevationContent = L.DomUtil.create('div', undefined, popup);
329
- elevationContent.textContent = `Elevation: ${item.position.y.toFixed(2)}`;
330
- if (item.top && item.bottom && item.top !== item.position.y && item.bottom !== item.position.y) {
331
- const heightContent = L.DomUtil.create('div', undefined, popup);
332
- heightContent.textContent = `Top ${item.top.toFixed(2)}, bottom: ${item.bottom.toFixed(2)}`;
333
- }
334
- }
335
-
336
- function markerIsOnLayer(marker, layer) {
337
- if (!layer) {
338
- return true;
339
- }
340
- var top = marker.options.top || marker.options.position.y;
341
- var bottom = marker.options.bottom || marker.options.position.y;
342
- for (const extent of layer.options.extents) {
343
- if (top >= extent.height[0] && bottom < extent.height[1]) {
344
- let containedType = 'partial';
345
- if (bottom >= extent.height[0] && top <= extent.height[1]) {
346
- containedType = 'full';
347
- }
348
- if (extent.bounds) {
349
- for (const boundsArray of extent.bounds) {
350
- const bounds = getBounds(boundsArray);
351
- if (bounds.contains(pos(marker.options.position))) {
352
- return containedType;
353
- }
354
- }
355
- } else {
356
- return containedType;
357
- }
358
- }
359
- }
360
- return false;
361
- }
362
-
363
- function markerIsOnActiveLayer(marker) {
364
- if (!marker.options.position) {
365
- return true;
366
- }
367
-
368
- const map = marker._map;
369
-
370
- // check if marker is completely contained by inactive layer
371
- const overlays = map.layerControl._layers.map(l => l.layer).filter(l => Boolean(l.options.extents) && l.options.overlay);
372
- for (const layer of overlays) {
373
- for (const extent of layer.options.extents) {
374
- if (markerIsOnLayer(marker, layer) === 'full' && !map.hasLayer(layer) && extent.bounds) {
375
- return false;
376
- }
377
- }
378
- }
379
-
380
- // check if marker is on active overlay
381
- const activeOverlay = Object.values(map._layers).find(l => l.options?.extents && l.options?.overlay);
382
- if (activeOverlay && markerIsOnLayer(marker, activeOverlay)) {
383
- return true;
384
- }
385
-
386
- // check if marker is on base layer
387
- const baseLayer = Object.values(map._layers).find(l => l.options?.extents && !L.options?.overlay);
388
- if (!activeOverlay && markerIsOnLayer(marker, baseLayer)) {
389
- return true;
390
- }
391
-
392
- return false;
393
- }
394
-
395
- function checkMarkerForActiveLayers(event) {
396
- const marker = event.target || event;
397
- const outline = marker.options.outline;
398
- const onLevel = markerIsOnActiveLayer(marker);
399
- if (onLevel) {
400
- marker._icon?.classList.remove('off-level');
401
- if (outline) {
402
- outline._path?.classList.remove('off-level');
403
- }
404
- } else {
405
- marker._icon?.classList.add('off-level');
406
- if (outline) {
407
- outline._path?.classList.add('off-level');
408
- }
409
- }
410
- }
411
-
412
- function activateMarkerLayer(event) {
413
- const marker = event.target || event;
414
- if (markerIsOnActiveLayer(marker)) {
415
- return;
416
- }
417
- const activeLayers = Object.values(marker._map._layers).filter(l => l.options?.extents && l.options?.overlay);
418
- for (const layer of activeLayers) {
419
- layer.removeFrom(marker._map);
420
- }
421
- const heightLayers = marker._map.layerControl._layers.filter(l => l.layer.options.extents && l.layer.options.overlay).map(l => l.layer);
422
- for (const layer of heightLayers) {
423
- if (markerIsOnLayer(marker, layer)) {
424
- layer.addTo(marker._map);
425
- break;
426
- }
427
- }
428
- }
429
-
430
- const getALink = (path, contents) => {
431
- const a = L.DomUtil.create('a');
432
- a.setAttribute('href', path);
433
- a.setAttribute('target', '_blank');
434
- a.append(contents);
435
- // a.addEventListener('click', (event) => {
436
- // navigate(path);
437
- // event.preventDefault();
438
- // });
439
- return a;
440
- };
441
-
442
- function getScaledBounds(bounds, scaleFactor) {
443
- // Calculate the center point of the bounds
444
- const centerX = (bounds[0][0] + bounds[1][0]) / 2;
445
- const centerY = (bounds[0][1] + bounds[1][1]) / 2;
446
-
447
- // Calculate the new width and height
448
- const width = bounds[1][0] - bounds[0][0];
449
- const height = bounds[1][1] - bounds[0][1];
450
- const newWidth = width * scaleFactor;
451
- const newHeight = height * scaleFactor;
452
-
453
- // Update the coordinates of the two points defining the bounds
454
- const newBounds = [
455
- [centerY - newHeight / 2, centerX - newWidth / 2],
456
- [centerY + newHeight / 2, centerX + newWidth / 2]
457
- ];
458
-
459
- // console.log("Initial Rectangle:", bounds);
460
- // console.log("Scaled Rectangle:", newBounds);
461
- // console.log("Center:", L.bounds(bounds).getCenter(true));
462
-
463
- return newBounds;
464
- }
465
-
466
- // Erstelle die Karte
467
- //const map = L.map('map').setView([0, 0], 2);
468
-
469
- const map = L.map('map', {
470
- maxBounds: getScaledBounds(svgBounds, 1.5),
471
- //maxBounds: bounds,
472
- center: [0, 0],
473
- zoom: 2,
474
- minZoom: minZoom,
475
- maxZoom: maxZoom,
476
- zoomSnap: 0.1,
477
- scrollWheelZoom: true,
478
- wheelPxPerZoomLevel: 120,
479
- crs: getCRS(transform),
480
- attributionControl: false,
481
- id: "wwoodsMap",
482
- });
483
-
484
- const layerControl = L.control.groupedLayers(null, null, {
485
- position: 'topleft',
486
- collapsed: true,
487
- groupCheckboxes: true,
488
- groupsCollapsable: true,
489
- exclusiveOptionalGroups: ['Levels'],
490
- }).addTo(map);
491
- layerControl.on('overlayToggle', (e) => {
492
- const layerState = e.detail;
493
- if (layerState.checked) {
494
- mapViewRef.current.layer = layerState.key;
495
- } else {
496
- mapViewRef.current.layer = undefined;
497
- }
498
- });
499
- layerControl.on('layerToggle', (e) => {
500
- const layerState = e.detail;
501
- if (!layerState.checked) {
502
- mapSettingsRef.current.hiddenLayers.push(layerState.key);
503
- } else {
504
- mapViewRef.current.layer = layerState.key;
505
- mapSettingsRef.current.hiddenLayers = mapSettingsRef.current.hiddenLayers.filter(key => key !== layerState.key);
506
- }
507
- updateSavedMapSettings();
508
- });
509
- layerControl.on('groupToggle', (e) => {
510
- const groupState = e.detail;
511
- for (const groupLayer of layerControl._layers) {
512
- if (groupLayer.group?.key !== groupState.key) {
513
- continue;
514
- }
515
- if (!groupState.checked) {
516
- mapSettingsRef.current.hiddenLayers.push(groupLayer.key);
517
- } else {
518
- mapSettingsRef.current.hiddenLayers = mapSettingsRef.current.hiddenLayers.filter(key => key !== groupLayer.key);
519
- }
520
- }
521
- if (!groupState.checked) {
522
- mapSettingsRef.current.hiddenGroups.push(groupState.key);
523
- } else {
524
- mapSettingsRef.current.hiddenGroups = mapSettingsRef.current.hiddenGroups.filter(key => key !== groupState.key);
525
- }
526
- updateSavedMapSettings();
527
- });
528
- layerControl.on('groupCollapseToggle', (e) => {
529
- const groupState = e.detail;
530
- if (groupState.collapsed) {
531
- mapSettingsRef.current.collapsedGroups.push(groupState.key);
532
-
533
- } else {
534
- mapSettingsRef.current.collapsedGroups = mapSettingsRef.current.collapsedGroups.filter(key => key !== groupState.key);
535
- }
536
- updateSavedMapSettings();
537
- });
538
-
539
- const getLayerOptions = (layerKey, groupKey, layerName) => {
540
- return {
541
- groupKey,
542
- layerKey,
543
- groupName: groupKey,
544
- layerName: layerName || categories[layerKey] || layerKey,
545
- //groupHidden: Boolean(mapSettingsRef.current.hiddenGroups?.includes(groupKey)),
546
- //layerHidden: Boolean(mapSettingsRef.current.hiddenLayers?.includes(layerKey)),
547
- image: images[layerKey] ? "/static/maps/interactive/${images[layerKey]}.png" : undefined,
548
- //groupCollapsed: Boolean(mapSettingsRef.current.collapsedGroups?.includes(groupKey)),
549
- };
550
- };
551
-
552
- const addLayer = (layer, layerKey, groupKey, layerName) => {
553
- layer.key = layerKey;
554
- const layerOptions = getLayerOptions(layerKey, groupKey, layerName);
555
- if (!layerOptions.layerHidden) {
556
- layer.addTo(map);
557
- }
558
- layerControl.addOverlay(layer, layerOptions.layerName, layerOptions);
559
- };
560
- map.layerControl = layerControl;
561
-
562
- // Hinzufügen des Image-Overlays
563
- const overlay = L.imageOverlay(imageUrl, getBounds(svgBounds));
564
- overlay.addTo(map);
565
-
566
- function checkMarkerBounds(position, markerBounds) {
567
- if (position.x < markerBounds.TL.x) markerBounds.TL.x = position.x;
568
- if (position.z > markerBounds.TL.z) markerBounds.TL.z = position.z;
569
- if (position.x > markerBounds.BR.x) markerBounds.BR.x = position.x;
570
- if (position.z < markerBounds.BR.z) markerBounds.BR.z = position.z;
571
- }
572
-
573
- function getBounds(bounds) {
574
- if (!bounds) {
575
- return undefined;
576
- }
577
- return L.latLngBounds([bounds[0][1], bounds[0][0]], [bounds[1][1], bounds[1][0]]);
578
- //return [[bounds[0][1], bounds[0][0]], [bounds[1][1], bounds[1][0]]];
579
- }
580
-
581
- function mouseHoverOutline(event) {
582
- const outline = event.target.options.outline;
583
- if (event.originalEvent.type === 'mouseover') {
584
- outline._path.classList.remove('not-shown');
585
- } else if (!outline._path.classList.contains('force-show')) {
586
- outline._path.classList.add('not-shown');
587
- }
588
- }
589
-
590
- function toggleForceOutline(event) {
591
- const outline = event.target.options.outline;
592
- outline._path.classList.toggle('force-show');
593
- if (outline._path.classList.contains('force-show')) {
594
- outline._path.classList.remove('not-shown');
595
- }
596
- activateMarkerLayer(event);
597
- }
598
-
599
- function activateMarkerLayer(event) {
600
- const marker = event.target || event;
601
- if (markerIsOnActiveLayer(marker)) {
602
- return;
603
- }
604
- const activeLayers = Object.values(marker._map._layers).filter(l => l.options?.extents && l.options?.overlay);
605
- for (const layer of activeLayers) {
606
- layer.removeFrom(marker._map);
607
- }
608
- const heightLayers = marker._map.layerControl._layers.filter(l => l.layer.options.extents && l.layer.options.overlay).map(l => l.layer);
609
- for (const layer of heightLayers) {
610
- if (markerIsOnLayer(marker, layer)) {
611
- layer.addTo(marker._map);
612
- break;
613
- }
614
- }
615
- }
616
-
617
- function outlineToPoly(outline) {
618
- if (!outline) return [];
619
- return outline.map(vector => [vector.z, vector.x]);
620
- }
621
-
622
- const layerOptions = {
623
- maxZoom: maxZoom,
624
- maxNativeZoom: maxZoom,
625
- extents: [
626
- {
627
- height: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
628
- bounds: [bounds],
629
- }
630
- ],
631
- type: 'map-layer',
632
- };
633
- let tileLayer = false;
634
- const baseLayers = [];
635
- const tileSize = 256;
636
- let svgLayer = false;
637
- if (svgPath) {
638
- const svgBounds2 = svgBounds ? getBounds(svgBounds) : bounds;
639
- svgLayer = L.imageOverlay(svgPath, svgBounds2, layerOptions);
640
- baseLayers.push(svgLayer);
641
- }
642
-
643
- const positionIsInBounds = (position) => {
644
- return getBounds(bounds).contains(pos(position));
645
- };
646
-
647
- let markerBounds = {
648
- 'TL': { x: Number.MAX_SAFE_INTEGER, z: Number.MIN_SAFE_INTEGER },
649
- 'BR': { x: Number.MIN_SAFE_INTEGER, z: Number.MAX_SAFE_INTEGER }
650
- }
651
-
652
- if (mapData.labels?.length > 0) {
653
- const labelsGroup = L.layerGroup();
654
- const defaultHeight = ((layerOptions.extents[0].height[1] - layerOptions.extents[0].height[0]) / 2) + layerOptions.extents[0].height[0];
655
- for (const label of mapData.labels) {
656
- const fontSize = label.size ? label.size : 100;
657
- const height = label.position.length < 3 ? defaultHeight : label.position[2];
658
- const rotation = label.rotation ? label.rotation : 0;
659
- L.marker(pos({ x: label.position[0], z: label.position[1] }), {
660
- icon: L.divIcon({ html: `<div class="label" style="font-size: ${fontSize}%; transform: translate3d(-50%, -50%, 0) rotate(${rotation}deg)">${label.text}</div>`, className: 'map-area-label', layers: baseLayers, }),
661
- interactive: false,
662
- zIndexOffset: -100000,
663
- position: {
664
- x: label.position[0],
665
- y: height,
666
- z: label.position[1],
667
- },
668
- top: typeof label.top !== 'undefined' ? label.top : 1000,
669
- bottom: typeof label.bottom !== 'undefined' ? label.bottom : -1000,
670
- }).addTo(labelsGroup);
671
- }
672
- addLayer(labelsGroup, 'place-names', 'Landmarks');
673
- //labelsGroup.addTo(map);
674
- }
675
-
676
- // Add spawns
677
- if (mapData.spawns.length > 0) {
678
- const spawnLayers = {
679
- 'pmc': L.layerGroup(),
680
- 'scav': L.layerGroup(),
681
- 'sniper_scav': L.layerGroup(),
682
- 'boss': L.layerGroup(),
683
- 'cultist-priest': L.layerGroup(),
684
- 'rogue': L.layerGroup(),
685
- 'bloodhound': L.layerGroup(),
686
- }
687
- for (const spawn of mapData.spawns) {
688
- if (!positionIsInBounds(spawn.position)) {
689
- continue;
690
- }
691
- let spawnType = '';
692
- let bosses = [];
693
-
694
- if (spawn.categories.includes('boss')) {
695
- bosses = mapData.bosses.filter(boss => boss.spawnLocations.some(sl => sl.spawnKey === spawn.zoneName));
696
- if (bosses.length === 0) {
697
- if (spawn.categories.includes('bot') && spawn.sides.includes('scav')) {
698
- spawnType = 'scav';
699
- }
700
- else {
701
- console.error(`Unusual spawn: ${spawn.sides}, ${spawn.categories}`);
702
- continue;
703
- }
704
- }
705
- else if (bosses.length === 1 && (bosses[0].normalizedName === 'bloodhound' || bosses[0].normalizedName === 'cultist-priest' || bosses[0].normalizedName === 'rogue')) {
706
- spawnType = bosses[0].normalizedName;
707
- }
708
- else {
709
- spawnType = 'boss';
710
- }
711
- } else if (spawn.categories.includes('sniper')) {
712
- spawnType = 'sniper_scav';
713
- } else if (spawn.sides.includes('scav')) {
714
- if (spawn.categories.includes('bot') || spawn.categories.includes('all')) {
715
- spawnType = 'scav';
716
- }
717
- else {
718
- console.error(`Unusual spawn: ${spawn.sides}, ${spawn.categories}`);
719
- continue;
720
- }
721
- }
722
- else if (spawn.categories.includes('player')) {
723
- if (spawn.sides.includes('pmc') || spawn.sides.includes('all')) {
724
- spawnType = 'pmc'
725
- }
726
- else {
727
- console.error(`Unusual spawn: ${spawn.sides}, ${spawn.categories}`);
728
- continue;
729
- }
730
- }
731
- else {
732
- console.error(`Unusual spawn: ${spawn.sides}, ${spawn.categories}`);
733
- continue;
734
- }
735
-
736
- const spawnIcon = L.icon({
737
- iconUrl: `/static/maps/interactive/spawn_${spawnType}.png`,
738
- iconSize: [24, 24],
739
- popupAnchor: [0, -12],
740
- });
741
-
742
- if (spawnType === 'pmc') {
743
- spawnIcon.iconAnchor = [12, 24];
744
- spawnIcon.popupAnchor = [0, -24];
745
- }
746
-
747
- const popupContent = L.DomUtil.create('div')
748
- if (spawn.categories.includes('boss') && bosses.length > 0) {
749
- bosses = bosses.reduce((unique, current) => {
750
- if (!unique.some(b => b.normalizedName === current.normalizedName)) {
751
- unique.push(current)
752
- if (!categories[`spawn_${current.normalizedName}`]) {
753
- categories[`spawn_${current.normalizedName}`] = current.name
754
- }
755
- }
756
- return unique;
757
- }, []);
758
- const bossList = L.DomUtil.create('div', undefined, popupContent)
759
- for (const boss of bosses) {
760
- if (bossList.childNodes.length > 0) {
761
- const comma = L.DomUtil.create('span', undefined, bossList)
762
- comma.textContent = ', '
763
- }
764
- bossList.append(getALink(`https://escapefromtarkov.fandom.com/wiki/Special:Search?scope=internal&query=${boss.name}`, `${boss.name} (${Math.round(boss.spawnChance * 100)}%)`))
765
- }
766
- }
767
- else {
768
- const spawnDiv = L.DomUtil.create('div', undefined, popupContent)
769
- spawnDiv.textContent = categories[`spawn_${spawnType}`]
770
- }
771
- addElevation(spawn, popupContent)
772
-
773
- const marker = L.marker(pos(spawn.position), {
774
- icon: spawnIcon,
775
- position: spawn.position,
776
- });
777
- if (popupContent.childNodes.length > 0) {
778
- marker.bindPopup(L.popup().setContent(popupContent))
779
- }
780
- marker.position = spawn.position
781
- marker.on('add', checkMarkerForActiveLayers)
782
- marker.on('click', activateMarkerLayer)
783
- marker.addTo(spawnLayers[spawnType])
784
-
785
- checkMarkerBounds(spawn.position, markerBounds)
786
- }
787
- for (const key in spawnLayers) {
788
- if (Object.keys(spawnLayers[key]._layers).length > 0) {
789
- addLayer(spawnLayers[key], `spawn_${key}`, 'Spawns')
790
- }
791
- }
792
- }
793
-
794
- //add extracts
795
- if (mapData.extracts.length > 0) {
796
- const extractLayers = {
797
- pmc: L.layerGroup(),
798
- scav: L.layerGroup(),
799
- shared: L.layerGroup(),
800
- }
801
- const zIndexOffsets = {
802
- pmc: 150,
803
- shared: 125,
804
- scav: 100,
805
- };
806
- for (const extract of mapData.extracts) {
807
- const faction = extract.faction ?? 'shared';
808
- if (!positionIsInBounds(extract.position)) {
809
- //continue;
810
- }
811
- const colorMap = {
812
- scav: '#ff7800',
813
- pmc: '#00e599',
814
- shared: '#00e4e5',
815
- }
816
- const rect = L.polygon(outlineToPoly(extract.outline), { color: colorMap[faction], weight: 1, className: 'not-shown' });
817
- const extractIcon = L.divIcon({
818
- className: 'extract-icon',
819
- html: `<img src="/static/maps/interactive/extract_${faction}.png"/><span class="extract-name ${faction}">${extract.name}</span>`,
820
- iconAnchor: [12, 12]
821
- });
822
- const extractMarker = L.marker(pos(extract.position), {
823
- icon: extractIcon,
824
- title: extract.name,
825
- zIndexOffset: zIndexOffsets[faction],
826
- position: extract.position,
827
- top: extract.top,
828
- bottom: extract.bottom,
829
- outline: rect,
830
- id: extract.id,
831
- });
832
- extractMarker.on('mouseover', mouseHoverOutline);
833
- extractMarker.on('mouseout', mouseHoverOutline);
834
- extractMarker.on('click', toggleForceOutline);
835
- if (extract.switches?.length > 0) {
836
- const popup = L.DomUtil.create('div');
837
- const textElement = L.DomUtil.create('div');
838
- textElement.textContent = `${tMaps('Activated by')}:`;
839
- popup.appendChild(textElement);
840
- for (const sw of extract.switches) {
841
- const linkElement = getPoiLinkElement(sw.id, 'switch');
842
- const nameElement = L.DomUtil.create('span');
843
- nameElement.innerHTML = `<strong>${sw.name}</strong>`;
844
- linkElement.append(nameElement);
845
- popup.appendChild(linkElement);
846
- }
847
- addElevation(extract, popup);
848
- extractMarker.bindPopup(L.popup().setContent(popup));
849
- } else if (showElevation) {
850
- const popup = L.DomUtil.create('div');
851
- addElevation(extract, popup);
852
- extractMarker.bindPopup(L.popup().setContent(popup));
853
- }
854
- extractMarker.on('add', checkMarkerForActiveLayers);
855
- L.layerGroup([rect, extractMarker]).addTo(extractLayers[faction]);
856
-
857
- checkMarkerBounds(extract.position, markerBounds);
858
- }
859
- if (mapData.transits.length > 0) {
860
- extractLayers.transit = L.layerGroup();
861
-
862
- for (const transit of mapData.transits) {
863
- if (!positionIsInBounds(transit.position)) {
864
- //continue;
865
- }
866
- const rect = L.polygon(outlineToPoly(transit.outline), { color: '#e53500', weight: 1, className: 'not-shown' });
867
- const transitIcon = L.divIcon({
868
- className: 'extract-icon',
869
- html: `<img src="/static/maps/interactive/extract_transit.png"/><span class="extract-name transit">${transit.description}</span>`,
870
- iconAnchor: [12, 12]
871
- });
872
- const transitMarker = L.marker(pos(transit.position), {
873
- icon: transitIcon,
874
- title: transit.description,
875
- zIndexOffset: zIndexOffsets.pmc,
876
- position: transit.position,
877
- top: transit.top,
878
- bottom: transit.bottom,
879
- outline: rect,
880
- id: transit.id,
881
- });
882
- transitMarker.on('mouseover', mouseHoverOutline);
883
- transitMarker.on('mouseout', mouseHoverOutline);
884
- transitMarker.on('click', toggleForceOutline);
885
- if (showElevation) {
886
- const popup = L.DomUtil.create('div');
887
- addElevation(transit, popup);
888
- transitMarker.bindPopup(L.popup().setContent(popup));
889
- }
890
- transitMarker.on('add', checkMarkerForActiveLayers);
891
- L.layerGroup([rect, transitMarker]).addTo(extractLayers.transit);
892
-
893
- checkMarkerBounds(transit.position, markerBounds);
894
- }
895
- }
896
- for (const key in extractLayers) {
897
- if (Object.keys(extractLayers[key]._layers).length > 0) {
898
- addLayer(extractLayers[key], `extract_${key}`, 'Extracts');
899
- }
900
- }
901
- }
902
-
903
- // Add static items
904
- if (showStaticMarkers) {
905
- for (const category in mapData) {
906
- const markerLayer = L.layerGroup();
907
-
908
- const items = mapData[category];
909
- for (const item of items) {
910
- const itemIcon = L.icon({
911
- iconUrl: `/static/maps/interactive/${category}.png`,
912
- iconSize: [24, 24],
913
- popupAnchor: [0, -12],
914
- //className: layerIncludesMarker(heightLayer, item) ? '' : 'off-level',
915
- });
916
- L.marker(pos(item.position), { icon: itemIcon, position: item.position })
917
- .bindPopup(L.popup().setContent(`${item.name}<br>Elevation: ${item.position.y}`))
918
- .addTo(markerLayer);
919
-
920
- checkMarkerBounds(item.position, markerBounds);
921
- }
922
-
923
- if (items.length > 0) {
924
- var section;
925
- if (category.startsWith('extract')) {
926
- section = 'Extracts';
927
- }
928
- else if (category.startsWith('spawn')) {
929
- section = 'Spawns';
930
- }
931
- else {
932
- section = 'Lootable Items';
933
- }
934
- markerLayer.addTo(map);
935
- addLayer(markerLayer, category, section);
936
- // layerControl.addOverlay(markerLayer, `<img src='${process.env.PUBLIC_URL}/maps/interactive/${category}.png' class='control-item-image' /> ${categories[category] || category}`, section);
937
- }
938
- }
939
- }
940
-
941
- // Erstelle ein neues Control-Element
942
- const customControl = L.Control.extend({
943
- onAdd: function (map) {
944
- this.container = L.DomUtil.create('div', 'custom-control leaflet-control-layers leaflet-control-layers-expanded')
945
- this.container.innerHTML = '<h2>Add Marker to Pos: </h2>'
946
- return this.container
947
- },
948
-
949
- updateText: function (html) {
950
- if (this.container) {
951
- this.container.innerHTML = html
952
- }
953
- },
954
-
955
- clearText: function () {
956
- if (this.container) {
957
- this.container.innerHTML = ''
958
- }
959
- },
960
-
961
- onRemove: function (map) {
962
- // Nichts zu tun hier
963
- }
964
- });
965
- const myControl = new customControl({ position: 'topright' })
966
- map.addControl(myControl)
967
-
968
- function startCountdown(elementId) {
969
- const element = document.getElementById(elementId);
970
- if (!element) {
971
- console.error(`Element with id ${elementId} not found.`);
972
- return;
973
- }
974
-
975
- //let secondsStart = Math.floor(new Date().getTime() / 1000.0) - parseInt(element.getAttribute('data-rade-end')) - 60
976
- let secondsStart = parseInt(element.getAttribute('data-seconds')) - 60
977
- let seconds = secondsStart
978
- if (isNaN(secondsStart)) {
979
- console.error('Invalid data-seconds attribute.');
980
- return;
981
- }
982
-
983
- const intervalId = setInterval(() => {
984
- if (!document.hidden) {
985
- //seconds = (secondsStart - parseInt(Math.floor(new Date().getTime() / 1000.0)))
986
- //localStorage.setItem('rade_data', JSON.stringify({ remaining_time: seconds }));
987
- seconds--
988
-
989
- if (seconds <= 0) {
990
- clearInterval(intervalId);
991
- element.textContent = '0:00:00';
992
- myControl.updateText("")
993
- document.querySelector("head > title").textContent = `${mapData.name} | Map with friends`
994
- return;
995
- }
996
-
997
- //seconds--;
998
- const hours = Math.floor(seconds / 3600);
999
- const minutes = Math.floor((seconds % 3600) / 60);
1000
- const remainingSeconds = seconds % 60;
1001
-
1002
- const timeString = `${hours}:${minutes.toString().padStart(2, '0')}:${remainingSeconds.toString().padStart(2, '0')}`;
1003
- element.textContent = timeString;
1004
- document.querySelector("head > title").textContent = `${mapData.name} | ${timeString}`
1005
- }
1006
- }, 1000);
1007
- }
1008
-
1009
- function addNewRadeData(new_html) {
1010
- myControl.updateText(new_html)
1011
- startCountdown("rade_time_remain")
1012
- };
1013
-
1014
- // Funktion zum Hinzufügen eines Markers
1015
- function addMarker(x, y, z, timestamp, preview = false) {
1016
- // Position validieren
1017
- const position = {
1018
- x: parseFloat(x),
1019
- y: parseFloat(y),
1020
- z: parseFloat(z)
1021
- };
1022
-
1023
- if (!positionIsInBounds(position)) {
1024
- console.error("Position außerhalb der Karte:", position);
1025
- return;
1026
- }
1027
-
1028
- // SVG-Icon als String mit dynamischer Farbe
1029
- const svgString = `
1030
- <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 384 512' class="marker-svg">
1031
- <path fill='currentColor' d='M172.3 501.7C27 291 0 269.4 0 192 0 86 86 0 192 0s192 86 192 192c0 77.4-27 99-172.3 309.7-9.5 13.8-29.9 13.8-39.5 0zM192 272c44.2 0 80-35.8 80-80s-35.8-80-80-80-80 35.8-80 80 35.8 80 80 80z'/>
1032
- </svg>
1033
- `;
1034
-
1035
- // DivIcon mit dynamischem SVG erstellen
1036
- const markerIcon = L.divIcon({
1037
- html: svgString,
1038
- className: 'custom-marker',
1039
- iconSize: [32, 32],
1040
- iconAnchor: [16, 32], // Spitze des Markers zeigt auf die Position
1041
- popupAnchor: [0, -32]
1042
- });
1043
-
1044
- // Alten Marker entfernen
1045
- if (currentMarker) {
1046
- map.removeLayer(currentMarker);
1047
- }
1048
-
1049
- // Neuen Marker erstellen
1050
- currentMarker = L.marker(pos(position), {
1051
- icon: markerIcon,
1052
- position: position,
1053
- title: `Koordinaten: ${x}, ${y}, ${z}`,
1054
- riseOnHover: true
1055
- });
1056
-
1057
- // Popup mit Informationen erstellen
1058
- const popupContent = `
1059
- <div class="marker-popup">
1060
- <strong>Koordinaten:</strong>
1061
- <span>X: ${x} Y: ${y} Z: ${z}</span>
1062
- ${preview ? `<img class="preview-image" src="${preview}"><br>` : ''}
1063
-
1064
- <small>${timestamp}</small>
1065
- </div>
1066
- `;
1067
-
1068
- currentMarker.bindPopup(popupContent, {
1069
- maxWidth: 250,
1070
- minWidth: 150,
1071
- autoClose: true,
1072
- closeOnClick: true
1073
- });
1074
-
1075
- // Marker zur Karte hinzufügen
1076
- currentMarker.addTo(map);
1077
-
1078
- // Karte auf Marker zentrieren
1079
- map.setView(pos(position), map.getZoom(), {
1080
- animate: true,
1081
- duration: 0.5
1082
- });
1083
-
1084
- console.log("Neuer Marker gesetzt:", position);
1085
- }
1086
-
1087
- document.onload = loadLocalData()
1088
-
1089
- // BULMA JAVASCRIPTS
1090
- document.addEventListener('DOMContentLoaded', () => {
1091
-
1092
- // Get all "navbar-burger" elements
1093
- const $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'), 0);
1094
-
1095
- // Add a click event on each of them
1096
- $navbarBurgers.forEach(el => {
1097
- el.addEventListener('click', () => {
1098
-
1099
- // Get the target from the "data-target" attribute
1100
- const target = el.dataset.target;
1101
- const $target = document.getElementById(target);
1102
-
1103
- // Toggle the "is-active" class on both the "navbar-burger" and the "navbar-menu"
1104
- el.classList.toggle('is-active');
1105
- $target.classList.toggle('is-active');
1106
-
1107
- });
1108
- });
1109
-
1110
- });
1111
-
1112
- // MODAL Trigger
1113
- document.addEventListener('DOMContentLoaded', () => {
1114
- // Functions to open and close a modal
1115
- function openModal($el) {
1116
- $el.classList.add('is-active');
1117
- }
1118
-
1119
- function closeModal($el) {
1120
- $el.classList.remove('is-active');
1121
- }
1122
-
1123
- function closeAllModals() {
1124
- (document.querySelectorAll('.modal') || []).forEach(($modal) => {
1125
- closeModal($modal);
1126
- });
1127
- }
1128
-
1129
- // Add a click event on buttons to open a specific modal
1130
- (document.querySelectorAll('.js-modal-trigger') || []).forEach(($trigger) => {
1131
- const modal = $trigger.dataset.target;
1132
- const $target = document.getElementById(modal);
1133
-
1134
- $trigger.addEventListener('click', () => {
1135
- openModal($target);
1136
- });
1137
- });
1138
-
1139
- // Add a click event on various child elements to close the parent modal
1140
- (document.querySelectorAll('.modal-background, .modal-close, .modal-card-head .delete, .modal-card-foot .button') || []).forEach(($close) => {
1141
- const $target = $close.closest('.modal');
1142
-
1143
- $close.addEventListener('click', () => {
1144
- closeModal($target);
1145
- });
1146
- });
1147
-
1148
- // Add a keyboard event to close all modals
1149
- document.addEventListener('keydown', (event) => {
1150
- if (event.key === "Escape") {
1151
- closeAllModals();
1152
- }
1153
- });
1154
- });
1155
- </script>
1156
- </body>
1157
-
1158
  </html>
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+
4
+ <head>
5
+ <meta charset="UTF-8" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+
8
+ <!--title>Tarkov Map with friends</title-->
9
+ <title>{{ maps[0].name }} | Map with friends</title>
10
+ <link rel="icon" type="image/x-icon" href="/static/favicon.ico" />
11
+ <link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css" />
12
+ <!--link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet-groupedlayercontrol/0.6.1/leaflet.groupedlayercontrol.css"/-->
13
+ <script src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js"></script>
14
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css" />
15
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@1.0.2/css/bulma.min.css" />
16
+ <link rel="stylesheet" href="/static/style.css" />
17
+ </head>
18
+
19
+ <body>
20
+ <nav class="navbar is-fixed-top" role="navigation" aria-label="main navigation">
21
+ <div class="navbar-brand">
22
+ <a class="navbar-item" href="https://bulma.io">
23
+ <svg width="640" height="160" viewBox="0 0 640 160" fill="none" xmlns="http://www.w3.org/2000/svg">
24
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M170 132.571V27.5908C170 25.5451 170.915 23.93 172.746 22.7456C174.576 21.5612 176.729 20.969 179.206 20.969H210.377C232.019 20.969 242.84 30.4441 242.84 49.3943C242.84 62.5303 238.264 71.0902 229.112 75.074C234.603 77.2275 238.748 80.2692 241.548 84.1992C244.347 88.1292 245.747 93.8627 245.747 101.4V104.791C245.747 116.743 242.84 125.437 237.026 130.875C231.211 136.312 223.351 139.031 213.445 139.031H179.206C176.514 139.031 174.307 138.385 172.584 137.093C170.861 135.801 170 134.293 170 132.571ZM190.834 120.619H209.085C219.529 120.619 224.751 114.751 224.751 103.015V100.431C224.751 94.401 223.432 90.0404 220.794 87.3486C218.156 84.6568 214.253 83.3109 209.085 83.3109H190.834V120.619ZM190.834 66.8371H208.923C213.122 66.8371 216.326 65.5989 218.533 63.1225C220.74 60.646 221.844 57.2544 221.844 52.9475C221.844 48.7483 220.686 45.4374 218.371 43.0148C216.057 40.5922 212.853 39.3809 208.762 39.3809H190.834V66.8371ZM260.283 103.015V27.4293C260.283 25.2759 261.306 23.6608 263.351 22.5841C265.397 21.5074 267.873 20.969 270.781 20.969C273.688 20.969 276.164 21.5074 278.21 22.5841C280.256 23.6608 281.279 25.2759 281.279 27.4293V103.015C281.279 115.397 287.2 121.588 299.044 121.588C310.888 121.588 316.81 115.397 316.81 103.015V27.4293C316.81 25.2759 317.833 23.6608 319.879 22.5841C321.925 21.5074 324.401 20.969 327.308 20.969C330.215 20.969 332.692 21.5074 334.738 22.5841C336.783 23.6608 337.806 25.2759 337.806 27.4293V103.015C337.806 115.72 334.28 125.061 327.227 131.036C320.175 137.012 310.781 140 299.044 140C287.308 140 277.914 137.039 270.861 131.117C263.809 125.195 260.283 115.828 260.283 103.015ZM356.703 132.409V27.4293C356.703 25.2759 357.725 23.6608 359.771 22.5841C361.817 21.5074 364.293 20.969 367.201 20.969C370.108 20.969 372.584 21.5074 374.63 22.5841C376.676 23.6608 377.699 25.2759 377.699 27.4293V120.619H417.106C419.044 120.619 420.579 121.534 421.709 123.365C422.84 125.195 423.405 127.349 423.405 129.825C423.405 132.301 422.84 134.455 421.709 136.285C420.579 138.116 419.044 139.031 417.106 139.031H365.908C363.432 139.031 361.279 138.439 359.448 137.254C357.618 136.07 356.703 134.455 356.703 132.409ZM434.872 132.409V31.467C434.872 27.9138 435.868 25.2759 437.86 23.5532C439.852 21.8304 442.355 20.969 445.37 20.969C449.354 20.969 452.423 21.6689 454.576 23.0686C456.729 24.4684 459.098 27.4832 461.682 32.1131L481.548 68.2907L501.413 32.1131C503.997 27.4832 506.393 24.4684 508.6 23.0686C510.808 21.6689 513.903 20.969 517.887 20.969C520.902 20.969 523.405 21.8304 525.397 23.5532C527.389 25.2759 528.385 27.9138 528.385 31.467V132.409C528.385 134.455 527.335 136.07 525.236 137.254C523.136 138.439 520.686 139.031 517.887 139.031C514.98 139.031 512.503 138.439 510.458 137.254C508.412 136.07 507.389 134.455 507.389 132.409V62.961L488.493 96.5545C486.985 99.354 484.616 100.754 481.386 100.754C478.264 100.754 475.949 99.354 474.441 96.5545L455.868 61.6689V132.409C455.868 134.455 454.818 136.07 452.719 137.254C450.619 138.439 448.17 139.031 445.37 139.031C442.463 139.031 439.987 138.439 437.941 137.254C435.895 136.07 434.872 134.455 434.872 132.409ZM539.529 130.31C539.529 130.094 539.637 129.556 539.852 128.694L571.023 27.1063C571.669 24.8452 573.257 23.0956 575.787 21.8573C578.318 20.6191 581.198 20 584.428 20C587.658 20 590.565 20.6191 593.149 21.8573C595.734 23.0956 597.349 24.8452 597.995 27.1063L629.166 128.694C629.381 129.556 629.489 130.094 629.489 130.31C629.489 132.678 628.035 134.724 625.128 136.447C622.221 138.17 619.26 139.031 616.245 139.031C612.261 139.031 609.892 137.631 609.139 134.832L603.001 113.351H566.016L559.879 134.832C559.125 137.631 556.756 139.031 552.773 139.031C549.65 139.031 546.662 138.197 543.809 136.528C540.956 134.859 539.529 132.786 539.529 130.31ZM570.377 96.8775H598.479L584.428 47.2948L570.377 96.8775Z" fill="black" class="bd-svg-black" />
25
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M0 110L10 40L50 0L100 50L70 80L110 120L50 160L0 110Z" fill="#00D1B2" />
26
+ </svg>
27
+
28
+ </a>
29
+
30
+ <a role="button" class="navbar-burger" aria-label="menu" aria-expanded="false" data-target="navbarBasicExample">
31
+ <span aria-hidden="true"></span>
32
+ <span aria-hidden="true"></span>
33
+ <span aria-hidden="true"></span>
34
+ <span aria-hidden="true"></span>
35
+ </a>
36
+ </div>
37
+
38
+ <div id="navbarBasicExample" class="navbar-menu">
39
+ <div class="navbar-start">
40
+ <a class="navbar-item">
41
+ Home
42
+ </a>
43
+ <div class="navbar-item has-dropdown is-hoverable">
44
+ <a class="navbar-link">Maps</a>
45
+ <div class="navbar-dropdown is-boxed">
46
+ <a href="/map/woods" class="navbar-item">Woods</a>
47
+ <a href="/map/shoreline" class="navbar-item">Shoreline</a>
48
+ <a href="/map/lighthouse" class="navbar-item">Lighthouse</a>
49
+ <a href="/map/customs" class="navbar-item">Customs</a>
50
+ <a href="/map/interchange" class="navbar-item">Interchange</a>
51
+ <a href="/map/streets-of-tarkov" class="navbar-item">Streets of Tarkov</a>
52
+ <a href="/map/ground-zero" class="navbar-item">Ground Zero</a>
53
+ <a href="/map/reserve" class="navbar-item">Reserve</a>
54
+ <a href="/map/factory" class="navbar-item">Factory</a>
55
+ </div>
56
+ </div>
57
+ </div>
58
+
59
+ <div class="navbar-end">
60
+ <div class="navbar-item">
61
+ <button class="button is-dark js-modal-trigger" data-target="settings-modal">
62
+ <span class="icon is-small">
63
+ <i class="fas fa-cog"></i>
64
+ </span>
65
+ </button>
66
+ </div>
67
+ </div>
68
+ </div>
69
+ </nav>
70
+
71
+ <div id="map"></div>
72
+
73
+
74
+ <div id="settings-modal" class="modal">
75
+ <div class="modal-background"></div>
76
+
77
+ <div class="modal-content container">
78
+ <div class="box">
79
+ <section class="hero">
80
+ <div class="hero-body">
81
+ <p class="title has-text-weight-bold">EINSTELLUNGEN</p>
82
+ <hr class="title-line">
83
+ <p class="subtitle">Subtitle</p>
84
+ </div>
85
+ </section>
86
+ <!-- Your content -->
87
+ <section class="section">
88
+ <div class="content">
89
+ <p>
90
+ Hier die Einstellungen basierend auf der config.ini file.
91
+
92
+ {#
93
+ [mainconfig]
94
+ eft_log_older_path = E:/Battlestate Games/Escape from Tarkov/Logs/
95
+ eft_screenshots_folder_path = C:/Users/Sebastian/Documents/Escape from Tarkov/Screenshots/
96
+ delete_screenshots = True
97
+ eft_show_exits_key = o
98
+ eft_take_screenshot_key = del #}
99
+ </p>
100
+ </div>
101
+ </section>
102
+ </div>
103
+ </div>
104
+
105
+ <button class="modal-close is-large" aria-label="close"></button>
106
+ </div>
107
+
108
+
109
+ <script src="/static/js/leaflet.controlGroupedlayer.js"></script>
110
+ <script src="/static/js/leaflet.controlCoordinates.js"></script>
111
+ <script>
112
+ // GLOBAL VARIABLE TO HOLD THE CURRENT MARKER
113
+ let currentMarker = null;
114
+ const client_id = Date.now()
115
+ const mapData = {{ maps[0] | tojson }}
116
+ console.info(mapData)
117
+ //const transform = [0.1855, 113.1, 0.1855, 167.8]
118
+ const transform = mapData.transform
119
+ const bounds = mapData.bounds
120
+ const svgBounds = mapData.svgBounds ? mapData.svgBounds : bounds
121
+ const coordinateRotation = mapData.coordinateRotation ? mapData.coordinateRotation : 0
122
+ const svgPath = mapData.svgPath
123
+ const imageUrl = mapData.svgPath
124
+ const minZoom = mapData.minZoom ? mapData.minZoom : 1
125
+ const maxZoom = mapData.maxZoom ? mapData.maxZoom : 6
126
+ const showElevation = false;
127
+ const showStaticMarkers = false
128
+
129
+ let currentZoom = 3;
130
+
131
+
132
+ const ws = new WebSocket(`wss://sebastiankay-eft-group-map-websocket.hf.space:8000/${client_id}`)
133
+ ws.onmessage = function (event) {
134
+ console.log(event.data);
135
+ const data = JSON.parse(event.data);
136
+ if (data.type === "coordinates") {
137
+ const parsedData = data.data;
138
+ localStorage.setItem("last_marker", JSON.stringify(parsedData));
139
+ loadLocalData();
140
+ }
141
+ if (data.type === "location_map") {
142
+ const map_name = data.data.map.toLowerCase().replaceAll(" ", "-")
143
+ localStorage.setItem("last_map_name", data.data.map.toLowerCase().replaceAll(" ", "-"));
144
+ localStorage.removeItem("last_marker")
145
+ if (!location.pathname.includes(map_name)) location.pathname = `/map/${map_name}`
146
+ else location.reload()
147
+ }
148
+ if (data.type == "new_rade_data") {
149
+ console.log(data.data)
150
+ const parsedData = JSON.parse(data.data);
151
+ localStorage.setItem("rade_data", JSON.stringify(parsedData));
152
+ loadLocalData();
153
+ }
154
+ };
155
+
156
+ ws.onopen = function (event) {
157
+ console.log(JSON.stringify({ type: "test_msg", data: "Test Message" }));
158
+ ws.send(JSON.stringify({ type: "test_msg", data: "Test Message" }));
159
+ };
160
+
161
+
162
+ function loadLocalData() {
163
+
164
+ const map_name = localStorage.getItem("last_map_name")
165
+ if (map_name) {
166
+ if (!location.pathname.includes(map_name)) localStorage.removeItem("last_marker")
167
+ } else localStorage.removeItem("last_marker")
168
+
169
+ const markerData = JSON.parse(localStorage.getItem("last_marker"))
170
+ console.log(markerData)
171
+ if (markerData) {
172
+ // Alten Marker entfernen
173
+ if (currentMarker) {
174
+ map.removeLayer(currentMarker);
175
+ currentMarker = null;
176
+ }
177
+ // Neuen Marker hinzufügen
178
+ addMarker(markerData.x, markerData.y, markerData.z, markerData.timestamp, markerData.preview ? markerData.preview : false);
179
+ }
180
+
181
+ const radeData = localStorage.getItem("rade_data");
182
+ if (radeData) {
183
+ const parsedData = JSON.parse(radeData);
184
+ // Process the loaded radeData as needed
185
+ console.log(parsedData);
186
+
187
+ if (parseInt(parsedData.rade_end_time) > Math.floor(new Date().getTime() / 1000.0)) {
188
+ // Rade is not over yet
189
+ console.log("Rade is not over yet")
190
+
191
+ const new_html = `
192
+ <div class="rade-time"><i class="fa-solid fa-door-open"></i> <h3 id="rade_time_remain" data-seconds="${parseInt(parsedData.rade_end_time) - Math.floor(new Date().getTime() / 1000.0)}" data-rade-end="${parsedData.rade_end_time}" data-rade-start="${parsedData.rade_start_time}" class="rade-time-remain">${parsedData.remaining_time}</h3></div>
193
+ <ul>
194
+ ${parsedData.extraction_exit_names.map(name => `<li><span class="tag exit">EXIT</span> ${name}</li>`).join('')}
195
+ ${parsedData.extraction_transit_names.map(name => `<li><span class="tag transit">TRANSIT</span> ${name.replaceAll("Transit ", "")}</li>`).join('')}
196
+ </ul>
197
+ `
198
+ addNewRadeData(new_html)
199
+ } else console.log("Rade is over")
200
+ }
201
+
202
+
203
+ };
204
+
205
+ const images = {
206
+ 'container_bank-cash-register': 'container_cash-register',
207
+ 'container_bank-safe': 'container_safe',
208
+ 'container_buried-barrel-cache': 'container_buried-barrel-cache',
209
+ 'container_cash-register': 'container_cash-register',
210
+ 'container_cash-register-tar2-2': 'container_cash-register',
211
+ 'container_dead-civilian': 'container_dead-scav',
212
+ 'container_dead-scav': 'container_dead-scav',
213
+ 'container_festive-airdrop-supply-crate': 'container_festive-airdrop-supply-crate',
214
+ 'container_pmc-body': 'container_dead-scav',
215
+ 'container_civilian-body': 'container_dead-scav',
216
+ 'container_drawer': 'container_drawer',
217
+ 'container_duffle-bag': 'container_duffle-bag',
218
+ 'container_grenade-box': 'container_grenade-box',
219
+ 'container_ground-cache': 'container_ground-cache',
220
+ 'container_jacket': 'container_jacket',
221
+ 'container_lab-technician-body': 'container_dead-scav',
222
+ 'container_medbag-smu06': 'container_medbag-smu06',
223
+ 'container_medcase': 'container_medcase',
224
+ 'container_medical-supply-crate': 'container_crate',
225
+ 'container_pc-block': 'container_pc-block',
226
+ 'container_plastic-suitcase': 'container_plastic-suitcase',
227
+ 'container_ration-supply-crate': 'container_crate',
228
+ 'container_safe': 'container_safe',
229
+ 'container_scav-body': 'container_dead-scav',
230
+ 'container_shturmans-stash': 'container_weapon-box',
231
+ 'container_technical-supply-crate': 'container_crate',
232
+ 'container_toolbox': 'container_toolbox',
233
+ 'container_weapon-box': 'container_weapon-box',
234
+ 'container_wooden-ammo-box': 'container_wooden-ammo-box',
235
+ 'container_wooden-crate': 'container_wooden-crate',
236
+ 'extract_pmc': 'extract_pmc',
237
+ 'extract_scav': 'extract_scav',
238
+ 'extract_shared': 'extract_shared',
239
+ 'extract_transit': 'extract_transit',
240
+ 'hazard': 'hazard',
241
+ 'hazard_mortar': 'hazard_mortar',
242
+ 'hazard_minefield': 'hazard',
243
+ 'hazard_sniper': 'hazard',
244
+ 'key': 'key',
245
+ 'lock': 'lock',
246
+ 'loose_loot': 'loose_loot',
247
+ 'quest_item': 'quest_item',
248
+ 'quest_objective': 'quest_objective',
249
+ 'spawn_sniper_scav': 'spawn_sniper_scav',
250
+ 'spawn_bloodhound': 'spawn_bloodhound',
251
+ 'spawn_boss': 'spawn_boss',
252
+ 'spawn_cultist-priest': 'spawn_cultist-priest',
253
+ 'spawn_pmc': 'spawn_pmc',
254
+ 'spawn_rogue': 'spawn_rogue',
255
+ 'spawn_scav': 'spawn_scav',
256
+ 'stationarygun': 'stationarygun',
257
+ 'switch': 'switch',
258
+ };
259
+
260
+ const categories = {
261
+ 'extract_pmc': 'PMC',
262
+ 'extract_shared': 'Shared',
263
+ 'extract_scav': 'Scav',
264
+ 'extract_transit': 'Transit',
265
+ 'spawn_sniper_scav': 'Sniper Scav',
266
+ 'spawn_pmc': 'PMC',
267
+ 'spawn_scav': 'Scav',
268
+ 'spawn_boss': 'Boss',
269
+ 'quest_item': 'Item',
270
+ 'quest_objective': 'Objective',
271
+ 'lock': 'Locks',
272
+ 'lever': 'Lever',
273
+ 'stationarygun': 'Stationary Gun',
274
+ 'switch': 'Switch',
275
+ 'place-names': 'Place Names',
276
+ };
277
+
278
+ function getCRS(transform) {
279
+ let scaleX = 1;
280
+ let scaleY = 1;
281
+ let marginX = 0;
282
+ let marginY = 0;
283
+ if (transform) {
284
+ scaleX = transform[0];
285
+ scaleY = transform[2] * -1;
286
+ marginX = transform[1];
287
+ marginY = transform[3];
288
+ }
289
+ return L.extend({}, L.CRS.Simple, {
290
+ transformation: new L.Transformation(scaleX, marginX, scaleY, marginY),
291
+ projection: L.extend({}, L.Projection.LonLat, {
292
+ project: latLng => {
293
+ return L.Projection.LonLat.project(applyRotation(latLng, coordinateRotation));
294
+ },
295
+ unproject: point => {
296
+ return applyRotation(L.Projection.LonLat.unproject(point), coordinateRotation * -1);
297
+ },
298
+ }),
299
+ });
300
+ }
301
+
302
+ function applyRotation(latLng, rotation) {
303
+ if (!latLng.lng && !latLng.lat) {
304
+ return L.latLng(0, 0);
305
+ }
306
+ if (!rotation) {
307
+ return latLng;
308
+ }
309
+
310
+ const angleInRadians = (rotation * Math.PI) / 180;
311
+ const cosAngle = Math.cos(angleInRadians);
312
+ const sinAngle = Math.sin(angleInRadians);
313
+
314
+ const { lng: x, lat: y } = latLng;
315
+ const rotatedX = x * cosAngle - y * sinAngle;
316
+ const rotatedY = x * sinAngle + y * cosAngle;
317
+ return L.latLng(rotatedY, rotatedX);
318
+ }
319
+
320
+ function pos(position) {
321
+ return [position.z, position.x];
322
+ }
323
+
324
+ function addElevation(item, popup) {
325
+ if (!showElevation) {
326
+ return;
327
+ }
328
+ const elevationContent = L.DomUtil.create('div', undefined, popup);
329
+ elevationContent.textContent = `Elevation: ${item.position.y.toFixed(2)}`;
330
+ if (item.top && item.bottom && item.top !== item.position.y && item.bottom !== item.position.y) {
331
+ const heightContent = L.DomUtil.create('div', undefined, popup);
332
+ heightContent.textContent = `Top ${item.top.toFixed(2)}, bottom: ${item.bottom.toFixed(2)}`;
333
+ }
334
+ }
335
+
336
+ function markerIsOnLayer(marker, layer) {
337
+ if (!layer) {
338
+ return true;
339
+ }
340
+ var top = marker.options.top || marker.options.position.y;
341
+ var bottom = marker.options.bottom || marker.options.position.y;
342
+ for (const extent of layer.options.extents) {
343
+ if (top >= extent.height[0] && bottom < extent.height[1]) {
344
+ let containedType = 'partial';
345
+ if (bottom >= extent.height[0] && top <= extent.height[1]) {
346
+ containedType = 'full';
347
+ }
348
+ if (extent.bounds) {
349
+ for (const boundsArray of extent.bounds) {
350
+ const bounds = getBounds(boundsArray);
351
+ if (bounds.contains(pos(marker.options.position))) {
352
+ return containedType;
353
+ }
354
+ }
355
+ } else {
356
+ return containedType;
357
+ }
358
+ }
359
+ }
360
+ return false;
361
+ }
362
+
363
+ function markerIsOnActiveLayer(marker) {
364
+ if (!marker.options.position) {
365
+ return true;
366
+ }
367
+
368
+ const map = marker._map;
369
+
370
+ // check if marker is completely contained by inactive layer
371
+ const overlays = map.layerControl._layers.map(l => l.layer).filter(l => Boolean(l.options.extents) && l.options.overlay);
372
+ for (const layer of overlays) {
373
+ for (const extent of layer.options.extents) {
374
+ if (markerIsOnLayer(marker, layer) === 'full' && !map.hasLayer(layer) && extent.bounds) {
375
+ return false;
376
+ }
377
+ }
378
+ }
379
+
380
+ // check if marker is on active overlay
381
+ const activeOverlay = Object.values(map._layers).find(l => l.options?.extents && l.options?.overlay);
382
+ if (activeOverlay && markerIsOnLayer(marker, activeOverlay)) {
383
+ return true;
384
+ }
385
+
386
+ // check if marker is on base layer
387
+ const baseLayer = Object.values(map._layers).find(l => l.options?.extents && !L.options?.overlay);
388
+ if (!activeOverlay && markerIsOnLayer(marker, baseLayer)) {
389
+ return true;
390
+ }
391
+
392
+ return false;
393
+ }
394
+
395
+ function checkMarkerForActiveLayers(event) {
396
+ const marker = event.target || event;
397
+ const outline = marker.options.outline;
398
+ const onLevel = markerIsOnActiveLayer(marker);
399
+ if (onLevel) {
400
+ marker._icon?.classList.remove('off-level');
401
+ if (outline) {
402
+ outline._path?.classList.remove('off-level');
403
+ }
404
+ } else {
405
+ marker._icon?.classList.add('off-level');
406
+ if (outline) {
407
+ outline._path?.classList.add('off-level');
408
+ }
409
+ }
410
+ }
411
+
412
+ function activateMarkerLayer(event) {
413
+ const marker = event.target || event;
414
+ if (markerIsOnActiveLayer(marker)) {
415
+ return;
416
+ }
417
+ const activeLayers = Object.values(marker._map._layers).filter(l => l.options?.extents && l.options?.overlay);
418
+ for (const layer of activeLayers) {
419
+ layer.removeFrom(marker._map);
420
+ }
421
+ const heightLayers = marker._map.layerControl._layers.filter(l => l.layer.options.extents && l.layer.options.overlay).map(l => l.layer);
422
+ for (const layer of heightLayers) {
423
+ if (markerIsOnLayer(marker, layer)) {
424
+ layer.addTo(marker._map);
425
+ break;
426
+ }
427
+ }
428
+ }
429
+
430
+ const getALink = (path, contents) => {
431
+ const a = L.DomUtil.create('a');
432
+ a.setAttribute('href', path);
433
+ a.setAttribute('target', '_blank');
434
+ a.append(contents);
435
+ // a.addEventListener('click', (event) => {
436
+ // navigate(path);
437
+ // event.preventDefault();
438
+ // });
439
+ return a;
440
+ };
441
+
442
+ function getScaledBounds(bounds, scaleFactor) {
443
+ // Calculate the center point of the bounds
444
+ const centerX = (bounds[0][0] + bounds[1][0]) / 2;
445
+ const centerY = (bounds[0][1] + bounds[1][1]) / 2;
446
+
447
+ // Calculate the new width and height
448
+ const width = bounds[1][0] - bounds[0][0];
449
+ const height = bounds[1][1] - bounds[0][1];
450
+ const newWidth = width * scaleFactor;
451
+ const newHeight = height * scaleFactor;
452
+
453
+ // Update the coordinates of the two points defining the bounds
454
+ const newBounds = [
455
+ [centerY - newHeight / 2, centerX - newWidth / 2],
456
+ [centerY + newHeight / 2, centerX + newWidth / 2]
457
+ ];
458
+
459
+ // console.log("Initial Rectangle:", bounds);
460
+ // console.log("Scaled Rectangle:", newBounds);
461
+ // console.log("Center:", L.bounds(bounds).getCenter(true));
462
+
463
+ return newBounds;
464
+ }
465
+
466
+ // Erstelle die Karte
467
+ //const map = L.map('map').setView([0, 0], 2);
468
+
469
+ const map = L.map('map', {
470
+ maxBounds: getScaledBounds(svgBounds, 1.5),
471
+ //maxBounds: bounds,
472
+ center: [0, 0],
473
+ zoom: 2,
474
+ minZoom: minZoom,
475
+ maxZoom: maxZoom,
476
+ zoomSnap: 0.1,
477
+ scrollWheelZoom: true,
478
+ wheelPxPerZoomLevel: 120,
479
+ crs: getCRS(transform),
480
+ attributionControl: false,
481
+ id: "wwoodsMap",
482
+ });
483
+
484
+ const layerControl = L.control.groupedLayers(null, null, {
485
+ position: 'topleft',
486
+ collapsed: true,
487
+ groupCheckboxes: true,
488
+ groupsCollapsable: true,
489
+ exclusiveOptionalGroups: ['Levels'],
490
+ }).addTo(map);
491
+ layerControl.on('overlayToggle', (e) => {
492
+ const layerState = e.detail;
493
+ if (layerState.checked) {
494
+ mapViewRef.current.layer = layerState.key;
495
+ } else {
496
+ mapViewRef.current.layer = undefined;
497
+ }
498
+ });
499
+ layerControl.on('layerToggle', (e) => {
500
+ const layerState = e.detail;
501
+ if (!layerState.checked) {
502
+ mapSettingsRef.current.hiddenLayers.push(layerState.key);
503
+ } else {
504
+ mapViewRef.current.layer = layerState.key;
505
+ mapSettingsRef.current.hiddenLayers = mapSettingsRef.current.hiddenLayers.filter(key => key !== layerState.key);
506
+ }
507
+ updateSavedMapSettings();
508
+ });
509
+ layerControl.on('groupToggle', (e) => {
510
+ const groupState = e.detail;
511
+ for (const groupLayer of layerControl._layers) {
512
+ if (groupLayer.group?.key !== groupState.key) {
513
+ continue;
514
+ }
515
+ if (!groupState.checked) {
516
+ mapSettingsRef.current.hiddenLayers.push(groupLayer.key);
517
+ } else {
518
+ mapSettingsRef.current.hiddenLayers = mapSettingsRef.current.hiddenLayers.filter(key => key !== groupLayer.key);
519
+ }
520
+ }
521
+ if (!groupState.checked) {
522
+ mapSettingsRef.current.hiddenGroups.push(groupState.key);
523
+ } else {
524
+ mapSettingsRef.current.hiddenGroups = mapSettingsRef.current.hiddenGroups.filter(key => key !== groupState.key);
525
+ }
526
+ updateSavedMapSettings();
527
+ });
528
+ layerControl.on('groupCollapseToggle', (e) => {
529
+ const groupState = e.detail;
530
+ if (groupState.collapsed) {
531
+ mapSettingsRef.current.collapsedGroups.push(groupState.key);
532
+
533
+ } else {
534
+ mapSettingsRef.current.collapsedGroups = mapSettingsRef.current.collapsedGroups.filter(key => key !== groupState.key);
535
+ }
536
+ updateSavedMapSettings();
537
+ });
538
+
539
+ const getLayerOptions = (layerKey, groupKey, layerName) => {
540
+ return {
541
+ groupKey,
542
+ layerKey,
543
+ groupName: groupKey,
544
+ layerName: layerName || categories[layerKey] || layerKey,
545
+ //groupHidden: Boolean(mapSettingsRef.current.hiddenGroups?.includes(groupKey)),
546
+ //layerHidden: Boolean(mapSettingsRef.current.hiddenLayers?.includes(layerKey)),
547
+ image: images[layerKey] ? "/static/maps/interactive/${images[layerKey]}.png" : undefined,
548
+ //groupCollapsed: Boolean(mapSettingsRef.current.collapsedGroups?.includes(groupKey)),
549
+ };
550
+ };
551
+
552
+ const addLayer = (layer, layerKey, groupKey, layerName) => {
553
+ layer.key = layerKey;
554
+ const layerOptions = getLayerOptions(layerKey, groupKey, layerName);
555
+ if (!layerOptions.layerHidden) {
556
+ layer.addTo(map);
557
+ }
558
+ layerControl.addOverlay(layer, layerOptions.layerName, layerOptions);
559
+ };
560
+ map.layerControl = layerControl;
561
+
562
+ // Hinzufügen des Image-Overlays
563
+ const overlay = L.imageOverlay(imageUrl, getBounds(svgBounds));
564
+ overlay.addTo(map);
565
+
566
+ function checkMarkerBounds(position, markerBounds) {
567
+ if (position.x < markerBounds.TL.x) markerBounds.TL.x = position.x;
568
+ if (position.z > markerBounds.TL.z) markerBounds.TL.z = position.z;
569
+ if (position.x > markerBounds.BR.x) markerBounds.BR.x = position.x;
570
+ if (position.z < markerBounds.BR.z) markerBounds.BR.z = position.z;
571
+ }
572
+
573
+ function getBounds(bounds) {
574
+ if (!bounds) {
575
+ return undefined;
576
+ }
577
+ return L.latLngBounds([bounds[0][1], bounds[0][0]], [bounds[1][1], bounds[1][0]]);
578
+ //return [[bounds[0][1], bounds[0][0]], [bounds[1][1], bounds[1][0]]];
579
+ }
580
+
581
+ function mouseHoverOutline(event) {
582
+ const outline = event.target.options.outline;
583
+ if (event.originalEvent.type === 'mouseover') {
584
+ outline._path.classList.remove('not-shown');
585
+ } else if (!outline._path.classList.contains('force-show')) {
586
+ outline._path.classList.add('not-shown');
587
+ }
588
+ }
589
+
590
+ function toggleForceOutline(event) {
591
+ const outline = event.target.options.outline;
592
+ outline._path.classList.toggle('force-show');
593
+ if (outline._path.classList.contains('force-show')) {
594
+ outline._path.classList.remove('not-shown');
595
+ }
596
+ activateMarkerLayer(event);
597
+ }
598
+
599
+ function activateMarkerLayer(event) {
600
+ const marker = event.target || event;
601
+ if (markerIsOnActiveLayer(marker)) {
602
+ return;
603
+ }
604
+ const activeLayers = Object.values(marker._map._layers).filter(l => l.options?.extents && l.options?.overlay);
605
+ for (const layer of activeLayers) {
606
+ layer.removeFrom(marker._map);
607
+ }
608
+ const heightLayers = marker._map.layerControl._layers.filter(l => l.layer.options.extents && l.layer.options.overlay).map(l => l.layer);
609
+ for (const layer of heightLayers) {
610
+ if (markerIsOnLayer(marker, layer)) {
611
+ layer.addTo(marker._map);
612
+ break;
613
+ }
614
+ }
615
+ }
616
+
617
+ function outlineToPoly(outline) {
618
+ if (!outline) return [];
619
+ return outline.map(vector => [vector.z, vector.x]);
620
+ }
621
+
622
+ const layerOptions = {
623
+ maxZoom: maxZoom,
624
+ maxNativeZoom: maxZoom,
625
+ extents: [
626
+ {
627
+ height: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
628
+ bounds: [bounds],
629
+ }
630
+ ],
631
+ type: 'map-layer',
632
+ };
633
+ let tileLayer = false;
634
+ const baseLayers = [];
635
+ const tileSize = 256;
636
+ let svgLayer = false;
637
+ if (svgPath) {
638
+ const svgBounds2 = svgBounds ? getBounds(svgBounds) : bounds;
639
+ svgLayer = L.imageOverlay(svgPath, svgBounds2, layerOptions);
640
+ baseLayers.push(svgLayer);
641
+ }
642
+
643
+ const positionIsInBounds = (position) => {
644
+ return getBounds(bounds).contains(pos(position));
645
+ };
646
+
647
+ let markerBounds = {
648
+ 'TL': { x: Number.MAX_SAFE_INTEGER, z: Number.MIN_SAFE_INTEGER },
649
+ 'BR': { x: Number.MIN_SAFE_INTEGER, z: Number.MAX_SAFE_INTEGER }
650
+ }
651
+
652
+ if (mapData.labels?.length > 0) {
653
+ const labelsGroup = L.layerGroup();
654
+ const defaultHeight = ((layerOptions.extents[0].height[1] - layerOptions.extents[0].height[0]) / 2) + layerOptions.extents[0].height[0];
655
+ for (const label of mapData.labels) {
656
+ const fontSize = label.size ? label.size : 100;
657
+ const height = label.position.length < 3 ? defaultHeight : label.position[2];
658
+ const rotation = label.rotation ? label.rotation : 0;
659
+ L.marker(pos({ x: label.position[0], z: label.position[1] }), {
660
+ icon: L.divIcon({ html: `<div class="label" style="font-size: ${fontSize}%; transform: translate3d(-50%, -50%, 0) rotate(${rotation}deg)">${label.text}</div>`, className: 'map-area-label', layers: baseLayers, }),
661
+ interactive: false,
662
+ zIndexOffset: -100000,
663
+ position: {
664
+ x: label.position[0],
665
+ y: height,
666
+ z: label.position[1],
667
+ },
668
+ top: typeof label.top !== 'undefined' ? label.top : 1000,
669
+ bottom: typeof label.bottom !== 'undefined' ? label.bottom : -1000,
670
+ }).addTo(labelsGroup);
671
+ }
672
+ addLayer(labelsGroup, 'place-names', 'Landmarks');
673
+ //labelsGroup.addTo(map);
674
+ }
675
+
676
+ // Add spawns
677
+ if (mapData.spawns.length > 0) {
678
+ const spawnLayers = {
679
+ 'pmc': L.layerGroup(),
680
+ 'scav': L.layerGroup(),
681
+ 'sniper_scav': L.layerGroup(),
682
+ 'boss': L.layerGroup(),
683
+ 'cultist-priest': L.layerGroup(),
684
+ 'rogue': L.layerGroup(),
685
+ 'bloodhound': L.layerGroup(),
686
+ }
687
+ for (const spawn of mapData.spawns) {
688
+ if (!positionIsInBounds(spawn.position)) {
689
+ continue;
690
+ }
691
+ let spawnType = '';
692
+ let bosses = [];
693
+
694
+ if (spawn.categories.includes('boss')) {
695
+ bosses = mapData.bosses.filter(boss => boss.spawnLocations.some(sl => sl.spawnKey === spawn.zoneName));
696
+ if (bosses.length === 0) {
697
+ if (spawn.categories.includes('bot') && spawn.sides.includes('scav')) {
698
+ spawnType = 'scav';
699
+ }
700
+ else {
701
+ console.error(`Unusual spawn: ${spawn.sides}, ${spawn.categories}`);
702
+ continue;
703
+ }
704
+ }
705
+ else if (bosses.length === 1 && (bosses[0].normalizedName === 'bloodhound' || bosses[0].normalizedName === 'cultist-priest' || bosses[0].normalizedName === 'rogue')) {
706
+ spawnType = bosses[0].normalizedName;
707
+ }
708
+ else {
709
+ spawnType = 'boss';
710
+ }
711
+ } else if (spawn.categories.includes('sniper')) {
712
+ spawnType = 'sniper_scav';
713
+ } else if (spawn.sides.includes('scav')) {
714
+ if (spawn.categories.includes('bot') || spawn.categories.includes('all')) {
715
+ spawnType = 'scav';
716
+ }
717
+ else {
718
+ console.error(`Unusual spawn: ${spawn.sides}, ${spawn.categories}`);
719
+ continue;
720
+ }
721
+ }
722
+ else if (spawn.categories.includes('player')) {
723
+ if (spawn.sides.includes('pmc') || spawn.sides.includes('all')) {
724
+ spawnType = 'pmc'
725
+ }
726
+ else {
727
+ console.error(`Unusual spawn: ${spawn.sides}, ${spawn.categories}`);
728
+ continue;
729
+ }
730
+ }
731
+ else {
732
+ console.error(`Unusual spawn: ${spawn.sides}, ${spawn.categories}`);
733
+ continue;
734
+ }
735
+
736
+ const spawnIcon = L.icon({
737
+ iconUrl: `/static/maps/interactive/spawn_${spawnType}.png`,
738
+ iconSize: [24, 24],
739
+ popupAnchor: [0, -12],
740
+ });
741
+
742
+ if (spawnType === 'pmc') {
743
+ spawnIcon.iconAnchor = [12, 24];
744
+ spawnIcon.popupAnchor = [0, -24];
745
+ }
746
+
747
+ const popupContent = L.DomUtil.create('div')
748
+ if (spawn.categories.includes('boss') && bosses.length > 0) {
749
+ bosses = bosses.reduce((unique, current) => {
750
+ if (!unique.some(b => b.normalizedName === current.normalizedName)) {
751
+ unique.push(current)
752
+ if (!categories[`spawn_${current.normalizedName}`]) {
753
+ categories[`spawn_${current.normalizedName}`] = current.name
754
+ }
755
+ }
756
+ return unique;
757
+ }, []);
758
+ const bossList = L.DomUtil.create('div', undefined, popupContent)
759
+ for (const boss of bosses) {
760
+ if (bossList.childNodes.length > 0) {
761
+ const comma = L.DomUtil.create('span', undefined, bossList)
762
+ comma.textContent = ', '
763
+ }
764
+ bossList.append(getALink(`https://escapefromtarkov.fandom.com/wiki/Special:Search?scope=internal&query=${boss.name}`, `${boss.name} (${Math.round(boss.spawnChance * 100)}%)`))
765
+ }
766
+ }
767
+ else {
768
+ const spawnDiv = L.DomUtil.create('div', undefined, popupContent)
769
+ spawnDiv.textContent = categories[`spawn_${spawnType}`]
770
+ }
771
+ addElevation(spawn, popupContent)
772
+
773
+ const marker = L.marker(pos(spawn.position), {
774
+ icon: spawnIcon,
775
+ position: spawn.position,
776
+ });
777
+ if (popupContent.childNodes.length > 0) {
778
+ marker.bindPopup(L.popup().setContent(popupContent))
779
+ }
780
+ marker.position = spawn.position
781
+ marker.on('add', checkMarkerForActiveLayers)
782
+ marker.on('click', activateMarkerLayer)
783
+ marker.addTo(spawnLayers[spawnType])
784
+
785
+ checkMarkerBounds(spawn.position, markerBounds)
786
+ }
787
+ for (const key in spawnLayers) {
788
+ if (Object.keys(spawnLayers[key]._layers).length > 0) {
789
+ addLayer(spawnLayers[key], `spawn_${key}`, 'Spawns')
790
+ }
791
+ }
792
+ }
793
+
794
+ //add extracts
795
+ if (mapData.extracts.length > 0) {
796
+ const extractLayers = {
797
+ pmc: L.layerGroup(),
798
+ scav: L.layerGroup(),
799
+ shared: L.layerGroup(),
800
+ }
801
+ const zIndexOffsets = {
802
+ pmc: 150,
803
+ shared: 125,
804
+ scav: 100,
805
+ };
806
+ for (const extract of mapData.extracts) {
807
+ const faction = extract.faction ?? 'shared';
808
+ if (!positionIsInBounds(extract.position)) {
809
+ //continue;
810
+ }
811
+ const colorMap = {
812
+ scav: '#ff7800',
813
+ pmc: '#00e599',
814
+ shared: '#00e4e5',
815
+ }
816
+ const rect = L.polygon(outlineToPoly(extract.outline), { color: colorMap[faction], weight: 1, className: 'not-shown' });
817
+ const extractIcon = L.divIcon({
818
+ className: 'extract-icon',
819
+ html: `<img src="/static/maps/interactive/extract_${faction}.png"/><span class="extract-name ${faction}">${extract.name}</span>`,
820
+ iconAnchor: [12, 12]
821
+ });
822
+ const extractMarker = L.marker(pos(extract.position), {
823
+ icon: extractIcon,
824
+ title: extract.name,
825
+ zIndexOffset: zIndexOffsets[faction],
826
+ position: extract.position,
827
+ top: extract.top,
828
+ bottom: extract.bottom,
829
+ outline: rect,
830
+ id: extract.id,
831
+ });
832
+ extractMarker.on('mouseover', mouseHoverOutline);
833
+ extractMarker.on('mouseout', mouseHoverOutline);
834
+ extractMarker.on('click', toggleForceOutline);
835
+ if (extract.switches?.length > 0) {
836
+ const popup = L.DomUtil.create('div');
837
+ const textElement = L.DomUtil.create('div');
838
+ textElement.textContent = `${tMaps('Activated by')}:`;
839
+ popup.appendChild(textElement);
840
+ for (const sw of extract.switches) {
841
+ const linkElement = getPoiLinkElement(sw.id, 'switch');
842
+ const nameElement = L.DomUtil.create('span');
843
+ nameElement.innerHTML = `<strong>${sw.name}</strong>`;
844
+ linkElement.append(nameElement);
845
+ popup.appendChild(linkElement);
846
+ }
847
+ addElevation(extract, popup);
848
+ extractMarker.bindPopup(L.popup().setContent(popup));
849
+ } else if (showElevation) {
850
+ const popup = L.DomUtil.create('div');
851
+ addElevation(extract, popup);
852
+ extractMarker.bindPopup(L.popup().setContent(popup));
853
+ }
854
+ extractMarker.on('add', checkMarkerForActiveLayers);
855
+ L.layerGroup([rect, extractMarker]).addTo(extractLayers[faction]);
856
+
857
+ checkMarkerBounds(extract.position, markerBounds);
858
+ }
859
+ if (mapData.transits.length > 0) {
860
+ extractLayers.transit = L.layerGroup();
861
+
862
+ for (const transit of mapData.transits) {
863
+ if (!positionIsInBounds(transit.position)) {
864
+ //continue;
865
+ }
866
+ const rect = L.polygon(outlineToPoly(transit.outline), { color: '#e53500', weight: 1, className: 'not-shown' });
867
+ const transitIcon = L.divIcon({
868
+ className: 'extract-icon',
869
+ html: `<img src="/static/maps/interactive/extract_transit.png"/><span class="extract-name transit">${transit.description}</span>`,
870
+ iconAnchor: [12, 12]
871
+ });
872
+ const transitMarker = L.marker(pos(transit.position), {
873
+ icon: transitIcon,
874
+ title: transit.description,
875
+ zIndexOffset: zIndexOffsets.pmc,
876
+ position: transit.position,
877
+ top: transit.top,
878
+ bottom: transit.bottom,
879
+ outline: rect,
880
+ id: transit.id,
881
+ });
882
+ transitMarker.on('mouseover', mouseHoverOutline);
883
+ transitMarker.on('mouseout', mouseHoverOutline);
884
+ transitMarker.on('click', toggleForceOutline);
885
+ if (showElevation) {
886
+ const popup = L.DomUtil.create('div');
887
+ addElevation(transit, popup);
888
+ transitMarker.bindPopup(L.popup().setContent(popup));
889
+ }
890
+ transitMarker.on('add', checkMarkerForActiveLayers);
891
+ L.layerGroup([rect, transitMarker]).addTo(extractLayers.transit);
892
+
893
+ checkMarkerBounds(transit.position, markerBounds);
894
+ }
895
+ }
896
+ for (const key in extractLayers) {
897
+ if (Object.keys(extractLayers[key]._layers).length > 0) {
898
+ addLayer(extractLayers[key], `extract_${key}`, 'Extracts');
899
+ }
900
+ }
901
+ }
902
+
903
+ // Add static items
904
+ if (showStaticMarkers) {
905
+ for (const category in mapData) {
906
+ const markerLayer = L.layerGroup();
907
+
908
+ const items = mapData[category];
909
+ for (const item of items) {
910
+ const itemIcon = L.icon({
911
+ iconUrl: `/static/maps/interactive/${category}.png`,
912
+ iconSize: [24, 24],
913
+ popupAnchor: [0, -12],
914
+ //className: layerIncludesMarker(heightLayer, item) ? '' : 'off-level',
915
+ });
916
+ L.marker(pos(item.position), { icon: itemIcon, position: item.position })
917
+ .bindPopup(L.popup().setContent(`${item.name}<br>Elevation: ${item.position.y}`))
918
+ .addTo(markerLayer);
919
+
920
+ checkMarkerBounds(item.position, markerBounds);
921
+ }
922
+
923
+ if (items.length > 0) {
924
+ var section;
925
+ if (category.startsWith('extract')) {
926
+ section = 'Extracts';
927
+ }
928
+ else if (category.startsWith('spawn')) {
929
+ section = 'Spawns';
930
+ }
931
+ else {
932
+ section = 'Lootable Items';
933
+ }
934
+ markerLayer.addTo(map);
935
+ addLayer(markerLayer, category, section);
936
+ // layerControl.addOverlay(markerLayer, `<img src='${process.env.PUBLIC_URL}/maps/interactive/${category}.png' class='control-item-image' /> ${categories[category] || category}`, section);
937
+ }
938
+ }
939
+ }
940
+
941
+ // Erstelle ein neues Control-Element
942
+ const customControl = L.Control.extend({
943
+ onAdd: function (map) {
944
+ this.container = L.DomUtil.create('div', 'custom-control leaflet-control-layers leaflet-control-layers-expanded')
945
+ this.container.innerHTML = '<h2>Add Marker to Pos: </h2>'
946
+ return this.container
947
+ },
948
+
949
+ updateText: function (html) {
950
+ if (this.container) {
951
+ this.container.innerHTML = html
952
+ }
953
+ },
954
+
955
+ clearText: function () {
956
+ if (this.container) {
957
+ this.container.innerHTML = ''
958
+ }
959
+ },
960
+
961
+ onRemove: function (map) {
962
+ // Nichts zu tun hier
963
+ }
964
+ });
965
+ const myControl = new customControl({ position: 'topright' })
966
+ map.addControl(myControl)
967
+
968
+ function startCountdown(elementId) {
969
+ const element = document.getElementById(elementId);
970
+ if (!element) {
971
+ console.error(`Element with id ${elementId} not found.`);
972
+ return;
973
+ }
974
+
975
+ //let secondsStart = Math.floor(new Date().getTime() / 1000.0) - parseInt(element.getAttribute('data-rade-end')) - 60
976
+ let secondsStart = parseInt(element.getAttribute('data-seconds')) - 60
977
+ let seconds = secondsStart
978
+ if (isNaN(secondsStart)) {
979
+ console.error('Invalid data-seconds attribute.');
980
+ return;
981
+ }
982
+
983
+ const intervalId = setInterval(() => {
984
+ if (!document.hidden) {
985
+ //seconds = (secondsStart - parseInt(Math.floor(new Date().getTime() / 1000.0)))
986
+ //localStorage.setItem('rade_data', JSON.stringify({ remaining_time: seconds }));
987
+ seconds--
988
+
989
+ if (seconds <= 0) {
990
+ clearInterval(intervalId);
991
+ element.textContent = '0:00:00';
992
+ myControl.updateText("")
993
+ document.querySelector("head > title").textContent = `${mapData.name} | Map with friends`
994
+ return;
995
+ }
996
+
997
+ //seconds--;
998
+ const hours = Math.floor(seconds / 3600);
999
+ const minutes = Math.floor((seconds % 3600) / 60);
1000
+ const remainingSeconds = seconds % 60;
1001
+
1002
+ const timeString = `${hours}:${minutes.toString().padStart(2, '0')}:${remainingSeconds.toString().padStart(2, '0')}`;
1003
+ element.textContent = timeString;
1004
+ document.querySelector("head > title").textContent = `${mapData.name} | ${timeString}`
1005
+ }
1006
+ }, 1000);
1007
+ }
1008
+
1009
+ function addNewRadeData(new_html) {
1010
+ myControl.updateText(new_html)
1011
+ startCountdown("rade_time_remain")
1012
+ };
1013
+
1014
+ // Funktion zum Hinzufügen eines Markers
1015
+ function addMarker(x, y, z, timestamp, preview = false) {
1016
+ // Position validieren
1017
+ const position = {
1018
+ x: parseFloat(x),
1019
+ y: parseFloat(y),
1020
+ z: parseFloat(z)
1021
+ };
1022
+
1023
+ if (!positionIsInBounds(position)) {
1024
+ console.error("Position außerhalb der Karte:", position);
1025
+ return;
1026
+ }
1027
+
1028
+ // SVG-Icon als String mit dynamischer Farbe
1029
+ const svgString = `
1030
+ <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 384 512' class="marker-svg">
1031
+ <path fill='currentColor' d='M172.3 501.7C27 291 0 269.4 0 192 0 86 86 0 192 0s192 86 192 192c0 77.4-27 99-172.3 309.7-9.5 13.8-29.9 13.8-39.5 0zM192 272c44.2 0 80-35.8 80-80s-35.8-80-80-80-80 35.8-80 80 35.8 80 80 80z'/>
1032
+ </svg>
1033
+ `;
1034
+
1035
+ // DivIcon mit dynamischem SVG erstellen
1036
+ const markerIcon = L.divIcon({
1037
+ html: svgString,
1038
+ className: 'custom-marker',
1039
+ iconSize: [32, 32],
1040
+ iconAnchor: [16, 32], // Spitze des Markers zeigt auf die Position
1041
+ popupAnchor: [0, -32]
1042
+ });
1043
+
1044
+ // Alten Marker entfernen
1045
+ if (currentMarker) {
1046
+ map.removeLayer(currentMarker);
1047
+ }
1048
+
1049
+ // Neuen Marker erstellen
1050
+ currentMarker = L.marker(pos(position), {
1051
+ icon: markerIcon,
1052
+ position: position,
1053
+ title: `Koordinaten: ${x}, ${y}, ${z}`,
1054
+ riseOnHover: true
1055
+ });
1056
+
1057
+ // Popup mit Informationen erstellen
1058
+ const popupContent = `
1059
+ <div class="marker-popup">
1060
+ <strong>Koordinaten:</strong>
1061
+ <span>X: ${x} Y: ${y} Z: ${z}</span>
1062
+ ${preview ? `<img class="preview-image" src="${preview}"><br>` : ''}
1063
+
1064
+ <small>${timestamp}</small>
1065
+ </div>
1066
+ `;
1067
+
1068
+ currentMarker.bindPopup(popupContent, {
1069
+ maxWidth: 250,
1070
+ minWidth: 150,
1071
+ autoClose: true,
1072
+ closeOnClick: true
1073
+ });
1074
+
1075
+ // Marker zur Karte hinzufügen
1076
+ currentMarker.addTo(map);
1077
+
1078
+ // Karte auf Marker zentrieren
1079
+ map.setView(pos(position), map.getZoom(), {
1080
+ animate: true,
1081
+ duration: 0.5
1082
+ });
1083
+
1084
+ console.log("Neuer Marker gesetzt:", position);
1085
+ }
1086
+
1087
+ document.onload = loadLocalData()
1088
+
1089
+ // BULMA JAVASCRIPTS
1090
+ document.addEventListener('DOMContentLoaded', () => {
1091
+
1092
+ // Get all "navbar-burger" elements
1093
+ const $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'), 0);
1094
+
1095
+ // Add a click event on each of them
1096
+ $navbarBurgers.forEach(el => {
1097
+ el.addEventListener('click', () => {
1098
+
1099
+ // Get the target from the "data-target" attribute
1100
+ const target = el.dataset.target;
1101
+ const $target = document.getElementById(target);
1102
+
1103
+ // Toggle the "is-active" class on both the "navbar-burger" and the "navbar-menu"
1104
+ el.classList.toggle('is-active');
1105
+ $target.classList.toggle('is-active');
1106
+
1107
+ });
1108
+ });
1109
+
1110
+ });
1111
+
1112
+ // MODAL Trigger
1113
+ document.addEventListener('DOMContentLoaded', () => {
1114
+ // Functions to open and close a modal
1115
+ function openModal($el) {
1116
+ $el.classList.add('is-active');
1117
+ }
1118
+
1119
+ function closeModal($el) {
1120
+ $el.classList.remove('is-active');
1121
+ }
1122
+
1123
+ function closeAllModals() {
1124
+ (document.querySelectorAll('.modal') || []).forEach(($modal) => {
1125
+ closeModal($modal);
1126
+ });
1127
+ }
1128
+
1129
+ // Add a click event on buttons to open a specific modal
1130
+ (document.querySelectorAll('.js-modal-trigger') || []).forEach(($trigger) => {
1131
+ const modal = $trigger.dataset.target;
1132
+ const $target = document.getElementById(modal);
1133
+
1134
+ $trigger.addEventListener('click', () => {
1135
+ openModal($target);
1136
+ });
1137
+ });
1138
+
1139
+ // Add a click event on various child elements to close the parent modal
1140
+ (document.querySelectorAll('.modal-background, .modal-close, .modal-card-head .delete, .modal-card-foot .button') || []).forEach(($close) => {
1141
+ const $target = $close.closest('.modal');
1142
+
1143
+ $close.addEventListener('click', () => {
1144
+ closeModal($target);
1145
+ });
1146
+ });
1147
+
1148
+ // Add a keyboard event to close all modals
1149
+ document.addEventListener('keydown', (event) => {
1150
+ if (event.key === "Escape") {
1151
+ closeAllModals();
1152
+ }
1153
+ });
1154
+ });
1155
+ </script>
1156
+ </body>
1157
+
1158
  </html>