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