Update templates/map.html
Browse files- templates/map.html +23 -9
templates/map.html
CHANGED
|
@@ -161,6 +161,18 @@
|
|
| 161 |
ws.send(JSON.stringify({ type: "join", group: wsgroup }));
|
| 162 |
};
|
| 163 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 164 |
|
| 165 |
function loadLocalData() {
|
| 166 |
|
|
@@ -173,10 +185,10 @@
|
|
| 173 |
console.log(markerData)
|
| 174 |
if (markerData) {
|
| 175 |
// Alten Marker entfernen
|
| 176 |
-
if (currentMarker) {
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
}
|
| 180 |
// Neuen Marker hinzufügen
|
| 181 |
addMarker(markerData.x, markerData.y, markerData.z, markerData.timestamp, markerData.preview ? markerData.preview : false, markerData.actualmap ? markerData.actualmap : false, markerData.playername ? markerData.playername : false, markerData.markercolor ? markerData.markercolor : false);
|
| 182 |
}
|
|
@@ -1016,6 +1028,8 @@
|
|
| 1016 |
|
| 1017 |
// Funktion zum Hinzufügen eines Markers
|
| 1018 |
function addMarker(x, y, z, timestamp, preview = false, actualmap = false, playername = false, markercolor = false) {
|
|
|
|
|
|
|
| 1019 |
|
| 1020 |
// Validate position
|
| 1021 |
const position = {
|
|
@@ -1051,12 +1065,12 @@
|
|
| 1051 |
});
|
| 1052 |
|
| 1053 |
// Remove old marker for this player, if it exists
|
| 1054 |
-
if (playerMarkers[
|
| 1055 |
-
map.removeLayer(playerMarkers[
|
| 1056 |
}
|
| 1057 |
|
| 1058 |
// Create new marker
|
| 1059 |
-
playerMarkers[
|
| 1060 |
icon: markerIcon,
|
| 1061 |
position: position,
|
| 1062 |
title: `Koordinaten: ${x}, ${y}, ${z}`,
|
|
@@ -1073,7 +1087,7 @@
|
|
| 1073 |
<small>${timestamp}</small>
|
| 1074 |
</div>
|
| 1075 |
`;
|
| 1076 |
-
playerMarkers[
|
| 1077 |
maxWidth: 250,
|
| 1078 |
minWidth: 150,
|
| 1079 |
autoClose: true,
|
|
@@ -1081,7 +1095,7 @@
|
|
| 1081 |
});
|
| 1082 |
|
| 1083 |
// Marker zur Karte hinzufügen
|
| 1084 |
-
playerMarkers[
|
| 1085 |
|
| 1086 |
// Karte auf Marker zentrieren
|
| 1087 |
map.setView(pos(position), map.getZoom(), {
|
|
|
|
| 161 |
ws.send(JSON.stringify({ type: "join", group: wsgroup }));
|
| 162 |
};
|
| 163 |
|
| 164 |
+
function removeAllMarkers() {
|
| 165 |
+
// Iterate over all player markers
|
| 166 |
+
for (const playername in playerMarkers) {
|
| 167 |
+
if (playerMarkers.hasOwnProperty(playername)) {
|
| 168 |
+
// Remove the marker from the map
|
| 169 |
+
map.removeLayer(playerMarkers[playername]);
|
| 170 |
+
}
|
| 171 |
+
}
|
| 172 |
+
// Clear the playerMarkers object
|
| 173 |
+
Object.keys(playerMarkers).forEach(key => delete playerMarkers[key]);
|
| 174 |
+
console.log("Alle Marker wurden entfernt.");
|
| 175 |
+
}
|
| 176 |
|
| 177 |
function loadLocalData() {
|
| 178 |
|
|
|
|
| 185 |
console.log(markerData)
|
| 186 |
if (markerData) {
|
| 187 |
// Alten Marker entfernen
|
| 188 |
+
// if (currentMarker) {
|
| 189 |
+
// map.removeLayer(currentMarker);
|
| 190 |
+
// currentMarker = null;
|
| 191 |
+
// }
|
| 192 |
// Neuen Marker hinzufügen
|
| 193 |
addMarker(markerData.x, markerData.y, markerData.z, markerData.timestamp, markerData.preview ? markerData.preview : false, markerData.actualmap ? markerData.actualmap : false, markerData.playername ? markerData.playername : false, markerData.markercolor ? markerData.markercolor : false);
|
| 194 |
}
|
|
|
|
| 1028 |
|
| 1029 |
// Funktion zum Hinzufügen eines Markers
|
| 1030 |
function addMarker(x, y, z, timestamp, preview = false, actualmap = false, playername = false, markercolor = false) {
|
| 1031 |
+
|
| 1032 |
+
const playerMarkerName = playername.toLowerCase().replaceAll(" ", "-")
|
| 1033 |
|
| 1034 |
// Validate position
|
| 1035 |
const position = {
|
|
|
|
| 1065 |
});
|
| 1066 |
|
| 1067 |
// Remove old marker for this player, if it exists
|
| 1068 |
+
if (playerMarkers[playerMarkerName]) {
|
| 1069 |
+
map.removeLayer(playerMarkers[playerMarkerName]);
|
| 1070 |
}
|
| 1071 |
|
| 1072 |
// Create new marker
|
| 1073 |
+
playerMarkers[playerMarkerName] = L.marker(pos(position), {
|
| 1074 |
icon: markerIcon,
|
| 1075 |
position: position,
|
| 1076 |
title: `Koordinaten: ${x}, ${y}, ${z}`,
|
|
|
|
| 1087 |
<small>${timestamp}</small>
|
| 1088 |
</div>
|
| 1089 |
`;
|
| 1090 |
+
playerMarkers[playerMarkerName].bindPopup(popupContent, {
|
| 1091 |
maxWidth: 250,
|
| 1092 |
minWidth: 150,
|
| 1093 |
autoClose: true,
|
|
|
|
| 1095 |
});
|
| 1096 |
|
| 1097 |
// Marker zur Karte hinzufügen
|
| 1098 |
+
playerMarkers[playerMarkerName].addTo(map);
|
| 1099 |
|
| 1100 |
// Karte auf Marker zentrieren
|
| 1101 |
map.setView(pos(position), map.getZoom(), {
|