Sebastiankay commited on
Commit
ca891a3
·
verified ·
1 Parent(s): 29deee2

Create map.html

Browse files
Files changed (1) hide show
  1. templates/map.html +1259 -0
templates/map.html ADDED
@@ -0,0 +1,1259 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ const playerMarkers = {}
114
+ let currentMarker = null
115
+ const client_id = Date.now()
116
+ const mapData = {{ maps[0] | tojson }}
117
+ console.info(mapData)
118
+ //const transform = [0.1855, 113.1, 0.1855, 167.8]
119
+ const transform = mapData.transform
120
+ const bounds = mapData.bounds
121
+ const svgBounds = mapData.svgBounds ? mapData.svgBounds : bounds
122
+ const coordinateRotation = mapData.coordinateRotation ? mapData.coordinateRotation : 0
123
+ const svgPath = mapData.svgPath
124
+ const imageUrl = mapData.svgPath
125
+ const minZoom = mapData.minZoom ? mapData.minZoom : 1
126
+ const maxZoom = mapData.maxZoom ? mapData.maxZoom : 6
127
+ const showElevation = false;
128
+ const showStaticMarkers = false
129
+ const wsgroup = "1234"
130
+
131
+ let currentZoom = 3;
132
+
133
+
134
+ // Initialize WebSocket connection
135
+ const ws = new WebSocket(`wss://sebastiankay-eft-group-map-websocket.hf.space/ws`);
136
+
137
+ // WebSocket event handlers
138
+ ws.onmessage = function(event) {
139
+ console.log(event.data);
140
+ const data = JSON.parse(event.data);
141
+
142
+ switch (data.type) {
143
+ case "coordinates":
144
+ const parsedData = data.data;
145
+ localStorage.setItem("last_marker", JSON.stringify(parsedData));
146
+ loadLocalData();
147
+ break;
148
+
149
+ case "location_map":
150
+ const map_name = data.data.map.toLowerCase().replaceAll(" ", "-");
151
+ localStorage.setItem("last_map_name", map_name);
152
+ localStorage.removeItem("last_marker");
153
+ removeAllMarkers(); // Clear all markers when the map changes
154
+ if (!location.pathname.includes(map_name)) {
155
+ location.pathname = `/map/${map_name}`;
156
+ } else {
157
+ location.reload();
158
+ }
159
+ break;
160
+
161
+ case "new_rade_data":
162
+ console.log(data.data);
163
+ const radeData = JSON.parse(data.data);
164
+ localStorage.setItem("rade_data", JSON.stringify(radeData));
165
+ loadLocalData();
166
+ break;
167
+ }
168
+ };
169
+
170
+ ws.onopen = function(event) {
171
+ ws.send(JSON.stringify({ type: "join", group: wsgroup }));
172
+ };
173
+
174
+ // Function to remove all markers
175
+ function removeAllMarkers() {
176
+ for (const playername in playerMarkers) {
177
+ if (playerMarkers.hasOwnProperty(playername)) {
178
+ map.removeLayer(playerMarkers[playername]);
179
+ }
180
+ }
181
+ Object.keys(playerMarkers).forEach(key => delete playerMarkers[key]);
182
+ console.log("Alle Marker wurden entfernt.");
183
+ }
184
+
185
+ // Function to load and display local marker data
186
+ function loadLocalData() {
187
+ const map_name = localStorage.getItem("last_map_name");
188
+ if (map_name) {
189
+ if (!location.pathname.includes(map_name)) {
190
+ localStorage.removeItem("last_marker");
191
+ }
192
+ } else {
193
+ localStorage.removeItem("last_marker");
194
+ }
195
+
196
+ const markerData = localStorage.getItem("last_marker");
197
+ if (markerData) {
198
+ const parsedData = JSON.parse(markerData);
199
+ // Use the new addMarker function with all required parameters
200
+ addMarker(
201
+ parsedData.x,
202
+ parsedData.y,
203
+ parsedData.z,
204
+ parsedData.timestamp,
205
+ parsedData.playername || "Unnamed Player",
206
+ parsedData.preview || false,
207
+ parsedData.actualmap || false,
208
+ parsedData.markercolor || false
209
+ );
210
+ }
211
+ }
212
+
213
+ const images = {
214
+ 'container_bank-cash-register': 'container_cash-register',
215
+ 'container_bank-safe': 'container_safe',
216
+ 'container_buried-barrel-cache': 'container_buried-barrel-cache',
217
+ 'container_cash-register': 'container_cash-register',
218
+ 'container_cash-register-tar2-2': 'container_cash-register',
219
+ 'container_dead-civilian': 'container_dead-scav',
220
+ 'container_dead-scav': 'container_dead-scav',
221
+ 'container_festive-airdrop-supply-crate': 'container_festive-airdrop-supply-crate',
222
+ 'container_pmc-body': 'container_dead-scav',
223
+ 'container_civilian-body': 'container_dead-scav',
224
+ 'container_drawer': 'container_drawer',
225
+ 'container_duffle-bag': 'container_duffle-bag',
226
+ 'container_grenade-box': 'container_grenade-box',
227
+ 'container_ground-cache': 'container_ground-cache',
228
+ 'container_jacket': 'container_jacket',
229
+ 'container_lab-technician-body': 'container_dead-scav',
230
+ 'container_medbag-smu06': 'container_medbag-smu06',
231
+ 'container_medcase': 'container_medcase',
232
+ 'container_medical-supply-crate': 'container_crate',
233
+ 'container_pc-block': 'container_pc-block',
234
+ 'container_plastic-suitcase': 'container_plastic-suitcase',
235
+ 'container_ration-supply-crate': 'container_crate',
236
+ 'container_safe': 'container_safe',
237
+ 'container_scav-body': 'container_dead-scav',
238
+ 'container_shturmans-stash': 'container_weapon-box',
239
+ 'container_technical-supply-crate': 'container_crate',
240
+ 'container_toolbox': 'container_toolbox',
241
+ 'container_weapon-box': 'container_weapon-box',
242
+ 'container_wooden-ammo-box': 'container_wooden-ammo-box',
243
+ 'container_wooden-crate': 'container_wooden-crate',
244
+ 'extract_pmc': 'extract_pmc',
245
+ 'extract_scav': 'extract_scav',
246
+ 'extract_shared': 'extract_shared',
247
+ 'extract_transit': 'extract_transit',
248
+ 'hazard': 'hazard',
249
+ 'hazard_mortar': 'hazard_mortar',
250
+ 'hazard_minefield': 'hazard',
251
+ 'hazard_sniper': 'hazard',
252
+ 'key': 'key',
253
+ 'lock': 'lock',
254
+ 'loose_loot': 'loose_loot',
255
+ 'quest_item': 'quest_item',
256
+ 'quest_objective': 'quest_objective',
257
+ 'spawn_sniper_scav': 'spawn_sniper_scav',
258
+ 'spawn_bloodhound': 'spawn_bloodhound',
259
+ 'spawn_boss': 'spawn_boss',
260
+ 'spawn_cultist-priest': 'spawn_cultist-priest',
261
+ 'spawn_pmc': 'spawn_pmc',
262
+ 'spawn_rogue': 'spawn_rogue',
263
+ 'spawn_scav': 'spawn_scav',
264
+ 'stationarygun': 'stationarygun',
265
+ 'switch': 'switch',
266
+ };
267
+
268
+ const categories = {
269
+ 'extract_pmc': 'PMC',
270
+ 'extract_shared': 'Shared',
271
+ 'extract_scav': 'Scav',
272
+ 'extract_transit': 'Transit',
273
+ 'spawn_sniper_scav': 'Sniper Scav',
274
+ 'spawn_pmc': 'PMC',
275
+ 'spawn_scav': 'Scav',
276
+ 'spawn_boss': 'Boss',
277
+ 'quest_item': 'Item',
278
+ 'quest_objective': 'Objective',
279
+ 'lock': 'Locks',
280
+ 'lever': 'Lever',
281
+ 'stationarygun': 'Stationary Gun',
282
+ 'switch': 'Switch',
283
+ 'place-names': 'Place Names',
284
+ };
285
+
286
+ function getCRS(transform) {
287
+ let scaleX = 1;
288
+ let scaleY = 1;
289
+ let marginX = 0;
290
+ let marginY = 0;
291
+ if (transform) {
292
+ scaleX = transform[0];
293
+ scaleY = transform[2] * -1;
294
+ marginX = transform[1];
295
+ marginY = transform[3];
296
+ }
297
+ return L.extend({}, L.CRS.Simple, {
298
+ transformation: new L.Transformation(scaleX, marginX, scaleY, marginY),
299
+ projection: L.extend({}, L.Projection.LonLat, {
300
+ project: latLng => {
301
+ return L.Projection.LonLat.project(applyRotation(latLng, coordinateRotation));
302
+ },
303
+ unproject: point => {
304
+ return applyRotation(L.Projection.LonLat.unproject(point), coordinateRotation * -1);
305
+ },
306
+ }),
307
+ });
308
+ }
309
+
310
+ function applyRotation(latLng, rotation) {
311
+ if (!latLng.lng && !latLng.lat) {
312
+ return L.latLng(0, 0);
313
+ }
314
+ if (!rotation) {
315
+ return latLng;
316
+ }
317
+
318
+ const angleInRadians = (rotation * Math.PI) / 180;
319
+ const cosAngle = Math.cos(angleInRadians);
320
+ const sinAngle = Math.sin(angleInRadians);
321
+
322
+ const { lng: x, lat: y } = latLng;
323
+ const rotatedX = x * cosAngle - y * sinAngle;
324
+ const rotatedY = x * sinAngle + y * cosAngle;
325
+ return L.latLng(rotatedY, rotatedX);
326
+ }
327
+
328
+ function pos(position) {
329
+ return [position.z, position.x];
330
+ }
331
+
332
+ function addElevation(item, popup) {
333
+ if (!showElevation) {
334
+ return;
335
+ }
336
+ const elevationContent = L.DomUtil.create('div', undefined, popup);
337
+ elevationContent.textContent = `Elevation: ${item.position.y.toFixed(2)}`;
338
+ if (item.top && item.bottom && item.top !== item.position.y && item.bottom !== item.position.y) {
339
+ const heightContent = L.DomUtil.create('div', undefined, popup);
340
+ heightContent.textContent = `Top ${item.top.toFixed(2)}, bottom: ${item.bottom.toFixed(2)}`;
341
+ }
342
+ }
343
+
344
+ function markerIsOnLayer(marker, layer) {
345
+ if (!layer) {
346
+ return true;
347
+ }
348
+ var top = marker.options.top || marker.options.position.y;
349
+ var bottom = marker.options.bottom || marker.options.position.y;
350
+ for (const extent of layer.options.extents) {
351
+ if (top >= extent.height[0] && bottom < extent.height[1]) {
352
+ let containedType = 'partial';
353
+ if (bottom >= extent.height[0] && top <= extent.height[1]) {
354
+ containedType = 'full';
355
+ }
356
+ if (extent.bounds) {
357
+ for (const boundsArray of extent.bounds) {
358
+ const bounds = getBounds(boundsArray);
359
+ if (bounds.contains(pos(marker.options.position))) {
360
+ return containedType;
361
+ }
362
+ }
363
+ } else {
364
+ return containedType;
365
+ }
366
+ }
367
+ }
368
+ return false;
369
+ }
370
+
371
+ function markerIsOnActiveLayer(marker) {
372
+ if (!marker.options.position) {
373
+ return true;
374
+ }
375
+
376
+ const map = marker._map;
377
+
378
+ // check if marker is completely contained by inactive layer
379
+ const overlays = map.layerControl._layers.map(l => l.layer).filter(l => Boolean(l.options.extents) && l.options.overlay);
380
+ for (const layer of overlays) {
381
+ for (const extent of layer.options.extents) {
382
+ if (markerIsOnLayer(marker, layer) === 'full' && !map.hasLayer(layer) && extent.bounds) {
383
+ return false;
384
+ }
385
+ }
386
+ }
387
+
388
+ // check if marker is on active overlay
389
+ const activeOverlay = Object.values(map._layers).find(l => l.options?.extents && l.options?.overlay);
390
+ if (activeOverlay && markerIsOnLayer(marker, activeOverlay)) {
391
+ return true;
392
+ }
393
+
394
+ // check if marker is on base layer
395
+ const baseLayer = Object.values(map._layers).find(l => l.options?.extents && !L.options?.overlay);
396
+ if (!activeOverlay && markerIsOnLayer(marker, baseLayer)) {
397
+ return true;
398
+ }
399
+
400
+ return false;
401
+ }
402
+
403
+ function checkMarkerForActiveLayers(event) {
404
+ const marker = event.target || event;
405
+ const outline = marker.options.outline;
406
+ const onLevel = markerIsOnActiveLayer(marker);
407
+ if (onLevel) {
408
+ marker._icon?.classList.remove('off-level');
409
+ if (outline) {
410
+ outline._path?.classList.remove('off-level');
411
+ }
412
+ } else {
413
+ marker._icon?.classList.add('off-level');
414
+ if (outline) {
415
+ outline._path?.classList.add('off-level');
416
+ }
417
+ }
418
+ }
419
+
420
+ function activateMarkerLayer(event) {
421
+ const marker = event.target || event;
422
+ if (markerIsOnActiveLayer(marker)) {
423
+ return;
424
+ }
425
+ const activeLayers = Object.values(marker._map._layers).filter(l => l.options?.extents && l.options?.overlay);
426
+ for (const layer of activeLayers) {
427
+ layer.removeFrom(marker._map);
428
+ }
429
+ const heightLayers = marker._map.layerControl._layers.filter(l => l.layer.options.extents && l.layer.options.overlay).map(l => l.layer);
430
+ for (const layer of heightLayers) {
431
+ if (markerIsOnLayer(marker, layer)) {
432
+ layer.addTo(marker._map);
433
+ break;
434
+ }
435
+ }
436
+ }
437
+
438
+ const getALink = (path, contents) => {
439
+ const a = L.DomUtil.create('a');
440
+ a.setAttribute('href', path);
441
+ a.setAttribute('target', '_blank');
442
+ a.append(contents);
443
+ // a.addEventListener('click', (event) => {
444
+ // navigate(path);
445
+ // event.preventDefault();
446
+ // });
447
+ return a;
448
+ };
449
+
450
+ function getScaledBounds(bounds, scaleFactor) {
451
+ // Calculate the center point of the bounds
452
+ const centerX = (bounds[0][0] + bounds[1][0]) / 2;
453
+ const centerY = (bounds[0][1] + bounds[1][1]) / 2;
454
+
455
+ // Calculate the new width and height
456
+ const width = bounds[1][0] - bounds[0][0];
457
+ const height = bounds[1][1] - bounds[0][1];
458
+ const newWidth = width * scaleFactor;
459
+ const newHeight = height * scaleFactor;
460
+
461
+ // Update the coordinates of the two points defining the bounds
462
+ const newBounds = [
463
+ [centerY - newHeight / 2, centerX - newWidth / 2],
464
+ [centerY + newHeight / 2, centerX + newWidth / 2]
465
+ ];
466
+
467
+ // console.log("Initial Rectangle:", bounds);
468
+ // console.log("Scaled Rectangle:", newBounds);
469
+ // console.log("Center:", L.bounds(bounds).getCenter(true));
470
+
471
+ return newBounds;
472
+ }
473
+
474
+ // Erstelle die Karte
475
+ //const map = L.map('map').setView([0, 0], 2);
476
+
477
+ const map = L.map('map', {
478
+ maxBounds: getScaledBounds(svgBounds, 1.5),
479
+ //maxBounds: bounds,
480
+ center: [0, 0],
481
+ zoom: 2,
482
+ minZoom: minZoom,
483
+ maxZoom: maxZoom,
484
+ zoomSnap: 0.1,
485
+ scrollWheelZoom: true,
486
+ wheelPxPerZoomLevel: 120,
487
+ crs: getCRS(transform),
488
+ attributionControl: false,
489
+ id: "wwoodsMap",
490
+ });
491
+
492
+ const layerControl = L.control.groupedLayers(null, null, {
493
+ position: 'topleft',
494
+ collapsed: true,
495
+ groupCheckboxes: true,
496
+ groupsCollapsable: true,
497
+ exclusiveOptionalGroups: ['Levels'],
498
+ }).addTo(map);
499
+ layerControl.on('overlayToggle', (e) => {
500
+ const layerState = e.detail;
501
+ if (layerState.checked) {
502
+ mapViewRef.current.layer = layerState.key;
503
+ } else {
504
+ mapViewRef.current.layer = undefined;
505
+ }
506
+ });
507
+ layerControl.on('layerToggle', (e) => {
508
+ const layerState = e.detail;
509
+ if (!layerState.checked) {
510
+ mapSettingsRef.current.hiddenLayers.push(layerState.key);
511
+ } else {
512
+ mapViewRef.current.layer = layerState.key;
513
+ mapSettingsRef.current.hiddenLayers = mapSettingsRef.current.hiddenLayers.filter(key => key !== layerState.key);
514
+ }
515
+ updateSavedMapSettings();
516
+ });
517
+ layerControl.on('groupToggle', (e) => {
518
+ const groupState = e.detail;
519
+ for (const groupLayer of layerControl._layers) {
520
+ if (groupLayer.group?.key !== groupState.key) {
521
+ continue;
522
+ }
523
+ if (!groupState.checked) {
524
+ mapSettingsRef.current.hiddenLayers.push(groupLayer.key);
525
+ } else {
526
+ mapSettingsRef.current.hiddenLayers = mapSettingsRef.current.hiddenLayers.filter(key => key !== groupLayer.key);
527
+ }
528
+ }
529
+ if (!groupState.checked) {
530
+ mapSettingsRef.current.hiddenGroups.push(groupState.key);
531
+ } else {
532
+ mapSettingsRef.current.hiddenGroups = mapSettingsRef.current.hiddenGroups.filter(key => key !== groupState.key);
533
+ }
534
+ updateSavedMapSettings();
535
+ });
536
+ layerControl.on('groupCollapseToggle', (e) => {
537
+ const groupState = e.detail;
538
+ if (groupState.collapsed) {
539
+ mapSettingsRef.current.collapsedGroups.push(groupState.key);
540
+
541
+ } else {
542
+ mapSettingsRef.current.collapsedGroups = mapSettingsRef.current.collapsedGroups.filter(key => key !== groupState.key);
543
+ }
544
+ updateSavedMapSettings();
545
+ });
546
+
547
+ const getLayerOptions = (layerKey, groupKey, layerName) => {
548
+ return {
549
+ groupKey,
550
+ layerKey,
551
+ groupName: groupKey,
552
+ layerName: layerName || categories[layerKey] || layerKey,
553
+ //groupHidden: Boolean(mapSettingsRef.current.hiddenGroups?.includes(groupKey)),
554
+ //layerHidden: Boolean(mapSettingsRef.current.hiddenLayers?.includes(layerKey)),
555
+ image: images[layerKey] ? "/static/maps/interactive/${images[layerKey]}.png" : undefined,
556
+ //groupCollapsed: Boolean(mapSettingsRef.current.collapsedGroups?.includes(groupKey)),
557
+ };
558
+ };
559
+
560
+ const addLayer = (layer, layerKey, groupKey, layerName) => {
561
+ layer.key = layerKey;
562
+ const layerOptions = getLayerOptions(layerKey, groupKey, layerName);
563
+ if (!layerOptions.layerHidden) {
564
+ layer.addTo(map);
565
+ }
566
+ layerControl.addOverlay(layer, layerOptions.layerName, layerOptions);
567
+ };
568
+ map.layerControl = layerControl;
569
+
570
+ // Hinzufügen des Image-Overlays
571
+ const overlay = L.imageOverlay(imageUrl, getBounds(svgBounds));
572
+ overlay.addTo(map);
573
+
574
+ function checkMarkerBounds(position, markerBounds) {
575
+ if (position.x < markerBounds.TL.x) markerBounds.TL.x = position.x;
576
+ if (position.z > markerBounds.TL.z) markerBounds.TL.z = position.z;
577
+ if (position.x > markerBounds.BR.x) markerBounds.BR.x = position.x;
578
+ if (position.z < markerBounds.BR.z) markerBounds.BR.z = position.z;
579
+ }
580
+
581
+ function getBounds(bounds) {
582
+ if (!bounds) {
583
+ return undefined;
584
+ }
585
+ return L.latLngBounds([bounds[0][1], bounds[0][0]], [bounds[1][1], bounds[1][0]]);
586
+ //return [[bounds[0][1], bounds[0][0]], [bounds[1][1], bounds[1][0]]];
587
+ }
588
+
589
+ function mouseHoverOutline(event) {
590
+ const outline = event.target.options.outline;
591
+ if (event.originalEvent.type === 'mouseover') {
592
+ outline._path.classList.remove('not-shown');
593
+ } else if (!outline._path.classList.contains('force-show')) {
594
+ outline._path.classList.add('not-shown');
595
+ }
596
+ }
597
+
598
+ function toggleForceOutline(event) {
599
+ const outline = event.target.options.outline;
600
+ outline._path.classList.toggle('force-show');
601
+ if (outline._path.classList.contains('force-show')) {
602
+ outline._path.classList.remove('not-shown');
603
+ }
604
+ activateMarkerLayer(event);
605
+ }
606
+
607
+ function activateMarkerLayer(event) {
608
+ const marker = event.target || event;
609
+ if (markerIsOnActiveLayer(marker)) {
610
+ return;
611
+ }
612
+ const activeLayers = Object.values(marker._map._layers).filter(l => l.options?.extents && l.options?.overlay);
613
+ for (const layer of activeLayers) {
614
+ layer.removeFrom(marker._map);
615
+ }
616
+ const heightLayers = marker._map.layerControl._layers.filter(l => l.layer.options.extents && l.layer.options.overlay).map(l => l.layer);
617
+ for (const layer of heightLayers) {
618
+ if (markerIsOnLayer(marker, layer)) {
619
+ layer.addTo(marker._map);
620
+ break;
621
+ }
622
+ }
623
+ }
624
+
625
+ function outlineToPoly(outline) {
626
+ if (!outline) return [];
627
+ return outline.map(vector => [vector.z, vector.x]);
628
+ }
629
+
630
+ const layerOptions = {
631
+ maxZoom: maxZoom,
632
+ maxNativeZoom: maxZoom,
633
+ extents: [
634
+ {
635
+ height: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
636
+ bounds: [bounds],
637
+ }
638
+ ],
639
+ type: 'map-layer',
640
+ };
641
+ let tileLayer = false;
642
+ const baseLayers = [];
643
+ const tileSize = 256;
644
+ let svgLayer = false;
645
+ if (svgPath) {
646
+ const svgBounds2 = svgBounds ? getBounds(svgBounds) : bounds;
647
+ svgLayer = L.imageOverlay(svgPath, svgBounds2, layerOptions);
648
+ baseLayers.push(svgLayer);
649
+ }
650
+
651
+ const positionIsInBounds = (position) => {
652
+ return getBounds(bounds).contains(pos(position));
653
+ };
654
+
655
+ let markerBounds = {
656
+ 'TL': { x: Number.MAX_SAFE_INTEGER, z: Number.MIN_SAFE_INTEGER },
657
+ 'BR': { x: Number.MIN_SAFE_INTEGER, z: Number.MAX_SAFE_INTEGER }
658
+ }
659
+
660
+ if (mapData.labels?.length > 0) {
661
+ const labelsGroup = L.layerGroup();
662
+ const defaultHeight = ((layerOptions.extents[0].height[1] - layerOptions.extents[0].height[0]) / 2) + layerOptions.extents[0].height[0];
663
+ for (const label of mapData.labels) {
664
+ const fontSize = label.size ? label.size : 100;
665
+ const height = label.position.length < 3 ? defaultHeight : label.position[2];
666
+ const rotation = label.rotation ? label.rotation : 0;
667
+ L.marker(pos({ x: label.position[0], z: label.position[1] }), {
668
+ 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, }),
669
+ interactive: false,
670
+ zIndexOffset: -100000,
671
+ position: {
672
+ x: label.position[0],
673
+ y: height,
674
+ z: label.position[1],
675
+ },
676
+ top: typeof label.top !== 'undefined' ? label.top : 1000,
677
+ bottom: typeof label.bottom !== 'undefined' ? label.bottom : -1000,
678
+ }).addTo(labelsGroup);
679
+ }
680
+ addLayer(labelsGroup, 'place-names', 'Landmarks');
681
+ //labelsGroup.addTo(map);
682
+ }
683
+
684
+ // Add spawns
685
+ if (mapData.spawns.length > 0) {
686
+ const spawnLayers = {
687
+ 'pmc': L.layerGroup(),
688
+ 'scav': L.layerGroup(),
689
+ 'sniper_scav': L.layerGroup(),
690
+ 'boss': L.layerGroup(),
691
+ 'cultist-priest': L.layerGroup(),
692
+ 'rogue': L.layerGroup(),
693
+ 'bloodhound': L.layerGroup(),
694
+ }
695
+ for (const spawn of mapData.spawns) {
696
+ if (!positionIsInBounds(spawn.position)) {
697
+ continue;
698
+ }
699
+ let spawnType = '';
700
+ let bosses = [];
701
+
702
+ if (spawn.categories.includes('boss')) {
703
+ bosses = mapData.bosses.filter(boss => boss.spawnLocations.some(sl => sl.spawnKey === spawn.zoneName));
704
+ if (bosses.length === 0) {
705
+ if (spawn.categories.includes('bot') && spawn.sides.includes('scav')) {
706
+ spawnType = 'scav';
707
+ }
708
+ else {
709
+ console.error(`Unusual spawn: ${spawn.sides}, ${spawn.categories}`);
710
+ continue;
711
+ }
712
+ }
713
+ else if (bosses.length === 1 && (bosses[0].normalizedName === 'bloodhound' || bosses[0].normalizedName === 'cultist-priest' || bosses[0].normalizedName === 'rogue')) {
714
+ spawnType = bosses[0].normalizedName;
715
+ }
716
+ else {
717
+ spawnType = 'boss';
718
+ }
719
+ } else if (spawn.categories.includes('sniper')) {
720
+ spawnType = 'sniper_scav';
721
+ } else if (spawn.sides.includes('scav')) {
722
+ if (spawn.categories.includes('bot') || spawn.categories.includes('all')) {
723
+ spawnType = 'scav';
724
+ }
725
+ else {
726
+ console.error(`Unusual spawn: ${spawn.sides}, ${spawn.categories}`);
727
+ continue;
728
+ }
729
+ }
730
+ else if (spawn.categories.includes('player')) {
731
+ if (spawn.sides.includes('pmc') || spawn.sides.includes('all')) {
732
+ spawnType = 'pmc'
733
+ }
734
+ else {
735
+ console.error(`Unusual spawn: ${spawn.sides}, ${spawn.categories}`);
736
+ continue;
737
+ }
738
+ }
739
+ else {
740
+ console.error(`Unusual spawn: ${spawn.sides}, ${spawn.categories}`);
741
+ continue;
742
+ }
743
+
744
+ const spawnIcon = L.icon({
745
+ iconUrl: `/static/maps/interactive/spawn_${spawnType}.png`,
746
+ iconSize: [24, 24],
747
+ popupAnchor: [0, -12],
748
+ });
749
+
750
+ if (spawnType === 'pmc') {
751
+ spawnIcon.iconAnchor = [12, 24];
752
+ spawnIcon.popupAnchor = [0, -24];
753
+ }
754
+
755
+ const popupContent = L.DomUtil.create('div')
756
+ if (spawn.categories.includes('boss') && bosses.length > 0) {
757
+ bosses = bosses.reduce((unique, current) => {
758
+ if (!unique.some(b => b.normalizedName === current.normalizedName)) {
759
+ unique.push(current)
760
+ if (!categories[`spawn_${current.normalizedName}`]) {
761
+ categories[`spawn_${current.normalizedName}`] = current.name
762
+ }
763
+ }
764
+ return unique;
765
+ }, []);
766
+ const bossList = L.DomUtil.create('div', undefined, popupContent)
767
+ for (const boss of bosses) {
768
+ if (bossList.childNodes.length > 0) {
769
+ const comma = L.DomUtil.create('span', undefined, bossList)
770
+ comma.textContent = ', '
771
+ }
772
+ bossList.append(getALink(`https://escapefromtarkov.fandom.com/wiki/Special:Search?scope=internal&query=${boss.name}`, `${boss.name} (${Math.round(boss.spawnChance * 100)}%)`))
773
+ }
774
+ }
775
+ else {
776
+ const spawnDiv = L.DomUtil.create('div', undefined, popupContent)
777
+ spawnDiv.textContent = categories[`spawn_${spawnType}`]
778
+ }
779
+ addElevation(spawn, popupContent)
780
+
781
+ const marker = L.marker(pos(spawn.position), {
782
+ icon: spawnIcon,
783
+ position: spawn.position,
784
+ });
785
+ if (popupContent.childNodes.length > 0) {
786
+ marker.bindPopup(L.popup().setContent(popupContent))
787
+ }
788
+ marker.position = spawn.position
789
+ marker.on('add', checkMarkerForActiveLayers)
790
+ marker.on('click', activateMarkerLayer)
791
+ marker.addTo(spawnLayers[spawnType])
792
+
793
+ checkMarkerBounds(spawn.position, markerBounds)
794
+ }
795
+ for (const key in spawnLayers) {
796
+ if (Object.keys(spawnLayers[key]._layers).length > 0) {
797
+ addLayer(spawnLayers[key], `spawn_${key}`, 'Spawns')
798
+ }
799
+ }
800
+ }
801
+
802
+ //add extracts
803
+ if (mapData.extracts.length > 0) {
804
+ const extractLayers = {
805
+ pmc: L.layerGroup(),
806
+ scav: L.layerGroup(),
807
+ shared: L.layerGroup(),
808
+ }
809
+ const zIndexOffsets = {
810
+ pmc: 150,
811
+ shared: 125,
812
+ scav: 100,
813
+ };
814
+ for (const extract of mapData.extracts) {
815
+ const faction = extract.faction ?? 'shared';
816
+ if (!positionIsInBounds(extract.position)) {
817
+ //continue;
818
+ }
819
+ const colorMap = {
820
+ scav: '#ff7800',
821
+ pmc: '#00e599',
822
+ shared: '#00e4e5',
823
+ }
824
+ const rect = L.polygon(outlineToPoly(extract.outline), { color: colorMap[faction], weight: 1, className: 'not-shown' });
825
+ const extractIcon = L.divIcon({
826
+ className: 'extract-icon',
827
+ html: `<img src="/static/maps/interactive/extract_${faction}.png"/><span class="extract-name ${faction}">${extract.name}</span>`,
828
+ iconAnchor: [12, 12]
829
+ });
830
+ const extractMarker = L.marker(pos(extract.position), {
831
+ icon: extractIcon,
832
+ title: extract.name,
833
+ zIndexOffset: zIndexOffsets[faction],
834
+ position: extract.position,
835
+ top: extract.top,
836
+ bottom: extract.bottom,
837
+ outline: rect,
838
+ id: extract.id,
839
+ });
840
+ extractMarker.on('mouseover', mouseHoverOutline);
841
+ extractMarker.on('mouseout', mouseHoverOutline);
842
+ extractMarker.on('click', toggleForceOutline);
843
+ if (extract.switches?.length > 0) {
844
+ const popup = L.DomUtil.create('div');
845
+ const textElement = L.DomUtil.create('div');
846
+ textElement.textContent = `${tMaps('Activated by')}:`;
847
+ popup.appendChild(textElement);
848
+ for (const sw of extract.switches) {
849
+ const linkElement = getPoiLinkElement(sw.id, 'switch');
850
+ const nameElement = L.DomUtil.create('span');
851
+ nameElement.innerHTML = `<strong>${sw.name}</strong>`;
852
+ linkElement.append(nameElement);
853
+ popup.appendChild(linkElement);
854
+ }
855
+ addElevation(extract, popup);
856
+ extractMarker.bindPopup(L.popup().setContent(popup));
857
+ } else if (showElevation) {
858
+ const popup = L.DomUtil.create('div');
859
+ addElevation(extract, popup);
860
+ extractMarker.bindPopup(L.popup().setContent(popup));
861
+ }
862
+ extractMarker.on('add', checkMarkerForActiveLayers);
863
+ L.layerGroup([rect, extractMarker]).addTo(extractLayers[faction]);
864
+
865
+ checkMarkerBounds(extract.position, markerBounds);
866
+ }
867
+ if (mapData.transits.length > 0) {
868
+ extractLayers.transit = L.layerGroup();
869
+
870
+ for (const transit of mapData.transits) {
871
+ if (!positionIsInBounds(transit.position)) {
872
+ //continue;
873
+ }
874
+ const rect = L.polygon(outlineToPoly(transit.outline), { color: '#e53500', weight: 1, className: 'not-shown' });
875
+ const transitIcon = L.divIcon({
876
+ className: 'extract-icon',
877
+ html: `<img src="/static/maps/interactive/extract_transit.png"/><span class="extract-name transit">${transit.description}</span>`,
878
+ iconAnchor: [12, 12]
879
+ });
880
+ const transitMarker = L.marker(pos(transit.position), {
881
+ icon: transitIcon,
882
+ title: transit.description,
883
+ zIndexOffset: zIndexOffsets.pmc,
884
+ position: transit.position,
885
+ top: transit.top,
886
+ bottom: transit.bottom,
887
+ outline: rect,
888
+ id: transit.id,
889
+ });
890
+ transitMarker.on('mouseover', mouseHoverOutline);
891
+ transitMarker.on('mouseout', mouseHoverOutline);
892
+ transitMarker.on('click', toggleForceOutline);
893
+ if (showElevation) {
894
+ const popup = L.DomUtil.create('div');
895
+ addElevation(transit, popup);
896
+ transitMarker.bindPopup(L.popup().setContent(popup));
897
+ }
898
+ transitMarker.on('add', checkMarkerForActiveLayers);
899
+ L.layerGroup([rect, transitMarker]).addTo(extractLayers.transit);
900
+
901
+ checkMarkerBounds(transit.position, markerBounds);
902
+ }
903
+ }
904
+ for (const key in extractLayers) {
905
+ if (Object.keys(extractLayers[key]._layers).length > 0) {
906
+ addLayer(extractLayers[key], `extract_${key}`, 'Extracts');
907
+ }
908
+ }
909
+ }
910
+
911
+ // Add static items
912
+ if (showStaticMarkers) {
913
+ for (const category in mapData) {
914
+ const markerLayer = L.layerGroup();
915
+
916
+ const items = mapData[category];
917
+ for (const item of items) {
918
+ const itemIcon = L.icon({
919
+ iconUrl: `/static/maps/interactive/${category}.png`,
920
+ iconSize: [24, 24],
921
+ popupAnchor: [0, -12],
922
+ //className: layerIncludesMarker(heightLayer, item) ? '' : 'off-level',
923
+ });
924
+ L.marker(pos(item.position), { icon: itemIcon, position: item.position })
925
+ .bindPopup(L.popup().setContent(`${item.name}<br>Elevation: ${item.position.y}`))
926
+ .addTo(markerLayer);
927
+
928
+ checkMarkerBounds(item.position, markerBounds);
929
+ }
930
+
931
+ if (items.length > 0) {
932
+ var section;
933
+ if (category.startsWith('extract')) {
934
+ section = 'Extracts';
935
+ }
936
+ else if (category.startsWith('spawn')) {
937
+ section = 'Spawns';
938
+ }
939
+ else {
940
+ section = 'Lootable Items';
941
+ }
942
+ markerLayer.addTo(map);
943
+ addLayer(markerLayer, category, section);
944
+ // layerControl.addOverlay(markerLayer, `<img src='${process.env.PUBLIC_URL}/maps/interactive/${category}.png' class='control-item-image' /> ${categories[category] || category}`, section);
945
+ }
946
+ }
947
+ }
948
+
949
+ // Erstelle ein neues Control-Element
950
+ const customControl = L.Control.extend({
951
+ onAdd: function (map) {
952
+ this.container = L.DomUtil.create('div', 'custom-control leaflet-control-layers leaflet-control-layers-expanded')
953
+ this.container.innerHTML = '<h2>Add Marker to Pos: </h2>'
954
+ return this.container
955
+ },
956
+
957
+ updateText: function (html) {
958
+ if (this.container) {
959
+ this.container.innerHTML = html
960
+ }
961
+ },
962
+
963
+ clearText: function () {
964
+ if (this.container) {
965
+ this.container.innerHTML = ''
966
+ }
967
+ },
968
+
969
+ onRemove: function (map) {
970
+ // Nichts zu tun hier
971
+ }
972
+ });
973
+ const myControl = new customControl({ position: 'topright' })
974
+ map.addControl(myControl)
975
+
976
+ function startCountdown(elementId) {
977
+ const element = document.getElementById(elementId);
978
+ if (!element) {
979
+ console.error(`Element with id ${elementId} not found.`);
980
+ return;
981
+ }
982
+
983
+ //let secondsStart = Math.floor(new Date().getTime() / 1000.0) - parseInt(element.getAttribute('data-rade-end')) - 60
984
+ let secondsStart = parseInt(element.getAttribute('data-seconds')) - 60
985
+ let seconds = secondsStart
986
+ if (isNaN(secondsStart)) {
987
+ console.error('Invalid data-seconds attribute.');
988
+ return;
989
+ }
990
+
991
+ const intervalId = setInterval(() => {
992
+ if (!document.hidden) {
993
+ //seconds = (secondsStart - parseInt(Math.floor(new Date().getTime() / 1000.0)))
994
+ //localStorage.setItem('rade_data', JSON.stringify({ remaining_time: seconds }));
995
+ seconds--
996
+
997
+ if (seconds <= 0) {
998
+ clearInterval(intervalId);
999
+ element.textContent = '0:00:00';
1000
+ myControl.updateText("")
1001
+ document.querySelector("head > title").textContent = `${mapData.name} | Map with friends`
1002
+ return;
1003
+ }
1004
+
1005
+ //seconds--;
1006
+ const hours = Math.floor(seconds / 3600);
1007
+ const minutes = Math.floor((seconds % 3600) / 60);
1008
+ const remainingSeconds = seconds % 60;
1009
+
1010
+ const timeString = `${hours}:${minutes.toString().padStart(2, '0')}:${remainingSeconds.toString().padStart(2, '0')}`;
1011
+ element.textContent = timeString;
1012
+ document.querySelector("head > title").textContent = `${mapData.name} | ${timeString}`
1013
+ }
1014
+ }, 1000);
1015
+ }
1016
+
1017
+ function addNewRadeData(new_html) {
1018
+ myControl.updateText(new_html)
1019
+ startCountdown("rade_time_remain")
1020
+ };
1021
+
1022
+ // Funktion zum Hinzufügen eines Markers
1023
+ function addMarker(x, y, z, timestamp, preview = false, actualmap = false, playername = false, markercolor = false) {
1024
+
1025
+ const playerMarkerName = playername.toLowerCase().replaceAll(" ", "-")
1026
+
1027
+ // Validate position
1028
+ const position = {
1029
+ x: parseFloat(x),
1030
+ y: parseFloat(y),
1031
+ z: parseFloat(z)
1032
+ };
1033
+ if (!positionIsInBounds(position)) {
1034
+ console.error("Position außerhalb der Karte:", position);
1035
+ return;
1036
+ }
1037
+
1038
+ // SVG-Icon als String mit dynamischer Farbe
1039
+ let markerColor;
1040
+ if (markercolor) {
1041
+ markerColor = '#' + markercolor;
1042
+ } else {
1043
+ markerColor = 'currentColor';
1044
+ }
1045
+ const svgString = `
1046
+ <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 384 512' class="marker-svg">
1047
+ <path fill='${markerColor}' 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'/>
1048
+ </svg>
1049
+ `;
1050
+
1051
+ // DivIcon mit dynamischem SVG erstellen
1052
+ const markerIcon = L.divIcon({
1053
+ html: svgString,
1054
+ className: 'custom-marker',
1055
+ iconSize: [32, 32],
1056
+ iconAnchor: [16, 32],
1057
+ popupAnchor: [0, -32]
1058
+ });
1059
+
1060
+ // Remove old marker for this player, if it exists
1061
+ if (playerMarkers[playerMarkerName]) {
1062
+ map.removeLayer(playerMarkers[playerMarkerName]);
1063
+ }
1064
+
1065
+ // Create new marker
1066
+ playerMarkers[playerMarkerName] = L.marker(pos(position), {
1067
+ icon: markerIcon,
1068
+ position: position,
1069
+ title: `Koordinaten: ${x}, ${y}, ${z}`,
1070
+ riseOnHover: true,
1071
+ zIndexOffset: 400
1072
+ });
1073
+
1074
+ // Popup mit Informationen erstellen
1075
+ const popupContent = `
1076
+ <div class="marker-popup">
1077
+ ${playername ? `<strong>Player: ${playername}</strong>` : ''}
1078
+ <strong>Koordinaten:</strong>
1079
+ <span>X: ${x} Y: ${y} Z: ${z}</span>
1080
+ ${preview ? `<img class="preview-image" src="${preview}"><br>` : ''}
1081
+ <small>${timestamp}</small>
1082
+ </div>
1083
+ `;
1084
+ playerMarkers[playerMarkerName].bindPopup(popupContent, {
1085
+ maxWidth: 250,
1086
+ minWidth: 150,
1087
+ autoClose: true,
1088
+ closeOnClick: true
1089
+ });
1090
+
1091
+ // Marker zur Karte hinzufügen
1092
+ playerMarkers[playerMarkerName].addTo(map);
1093
+
1094
+ // Karte auf Marker zentrieren
1095
+ map.setView(pos(position), map.getZoom(), {
1096
+ animate: true,
1097
+ duration: 0.5
1098
+ });
1099
+
1100
+ console.log("Neuer Marker gesetzt für " + playername + ": " + position);
1101
+ }
1102
+
1103
+
1104
+ function addMarker_OLD(x, y, z, timestamp, preview = false, actualmap = false, playername = false, markercolor = false) {
1105
+ // Position validieren
1106
+
1107
+ const position = {
1108
+ x: parseFloat(x),
1109
+ y: parseFloat(y),
1110
+ z: parseFloat(z)
1111
+ };
1112
+
1113
+ if (!positionIsInBounds(position)) {
1114
+ console.error("Position außerhalb der Karte:", position);
1115
+ return;
1116
+ }
1117
+
1118
+ // SVG-Icon als String mit dynamischer Farbe
1119
+
1120
+ let markerColor;
1121
+
1122
+ if (markercolor) {
1123
+ markerColor = '#' + markercolor;
1124
+ } else {
1125
+ markerColor = 'currentColor';
1126
+ }
1127
+ const svgString = `
1128
+ <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 384 512' class="marker-svg">
1129
+ <path fill='${markerColor}' 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'/>
1130
+ </svg>
1131
+ `;
1132
+
1133
+ // DivIcon mit dynamischem SVG erstellen
1134
+ const markerIcon = L.divIcon({
1135
+ html: svgString,
1136
+ className: 'custom-marker',
1137
+ iconSize: [32, 32],
1138
+ iconAnchor: [16, 32], // Spitze des Markers zeigt auf die Position
1139
+ popupAnchor: [0, -32]
1140
+ });
1141
+
1142
+ // Alten Marker entfernen
1143
+ if (currentMarker) {
1144
+ map.removeLayer(currentMarker);
1145
+ }
1146
+
1147
+ // Neuen Marker erstellen
1148
+ currentMarker = L.marker(pos(position), {
1149
+ icon: markerIcon,
1150
+ position: position,
1151
+ title: `Koordinaten: ${x}, ${y}, ${z}`,
1152
+ riseOnHover: true
1153
+ });
1154
+
1155
+ // Popup mit Informationen erstellen
1156
+ const popupContent = `
1157
+ <div class="marker-popup">
1158
+ ${playername ? `<strong>Player: ${playername}</strong>` : ''}
1159
+ <strong>Koordinaten:</strong>
1160
+ <span>X: ${x} Y: ${y} Z: ${z}</span>
1161
+ ${preview ? `<img class="preview-image" src="${preview}"><br>` : ''}
1162
+
1163
+ <small>${timestamp}</small>
1164
+ </div>
1165
+ `;
1166
+
1167
+ currentMarker.bindPopup(popupContent, {
1168
+ maxWidth: 250,
1169
+ minWidth: 150,
1170
+ autoClose: true,
1171
+ closeOnClick: true
1172
+ });
1173
+
1174
+ // Marker zur Karte hinzufügen
1175
+ currentMarker.addTo(map);
1176
+
1177
+ // Karte auf Marker zentrieren
1178
+ map.setView(pos(position), map.getZoom(), {
1179
+ animate: true,
1180
+ duration: 0.5
1181
+ });
1182
+
1183
+ console.log("Neuer Marker gesetzt: " + position);
1184
+ console.log("currentMarker: ")
1185
+ console.log(currentMarker)
1186
+ }
1187
+
1188
+ document.onload = loadLocalData()
1189
+
1190
+ // BULMA JAVASCRIPTS
1191
+ document.addEventListener('DOMContentLoaded', () => {
1192
+
1193
+ // Get all "navbar-burger" elements
1194
+ const $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'), 0);
1195
+
1196
+ // Add a click event on each of them
1197
+ $navbarBurgers.forEach(el => {
1198
+ el.addEventListener('click', () => {
1199
+
1200
+ // Get the target from the "data-target" attribute
1201
+ const target = el.dataset.target;
1202
+ const $target = document.getElementById(target);
1203
+
1204
+ // Toggle the "is-active" class on both the "navbar-burger" and the "navbar-menu"
1205
+ el.classList.toggle('is-active');
1206
+ $target.classList.toggle('is-active');
1207
+
1208
+ });
1209
+ });
1210
+
1211
+ });
1212
+
1213
+ // MODAL Trigger
1214
+ document.addEventListener('DOMContentLoaded', () => {
1215
+ // Functions to open and close a modal
1216
+ function openModal($el) {
1217
+ $el.classList.add('is-active');
1218
+ }
1219
+
1220
+ function closeModal($el) {
1221
+ $el.classList.remove('is-active');
1222
+ }
1223
+
1224
+ function closeAllModals() {
1225
+ (document.querySelectorAll('.modal') || []).forEach(($modal) => {
1226
+ closeModal($modal);
1227
+ });
1228
+ }
1229
+
1230
+ // Add a click event on buttons to open a specific modal
1231
+ (document.querySelectorAll('.js-modal-trigger') || []).forEach(($trigger) => {
1232
+ const modal = $trigger.dataset.target;
1233
+ const $target = document.getElementById(modal);
1234
+
1235
+ $trigger.addEventListener('click', () => {
1236
+ openModal($target);
1237
+ });
1238
+ });
1239
+
1240
+ // Add a click event on various child elements to close the parent modal
1241
+ (document.querySelectorAll('.modal-background, .modal-close, .modal-card-head .delete, .modal-card-foot .button') || []).forEach(($close) => {
1242
+ const $target = $close.closest('.modal');
1243
+
1244
+ $close.addEventListener('click', () => {
1245
+ closeModal($target);
1246
+ });
1247
+ });
1248
+
1249
+ // Add a keyboard event to close all modals
1250
+ document.addEventListener('keydown', (event) => {
1251
+ if (event.key === "Escape") {
1252
+ closeAllModals();
1253
+ }
1254
+ });
1255
+ });
1256
+ </script>
1257
+ </body>
1258
+
1259
+ </html>