WIP: Station öffnen in Kontextmenü für Tooltip
This commit is contained in:
@@ -12,7 +12,20 @@ export const initializeMap = (mapRef, setMap, setOms, setMenuItemAdded, addItems
|
||||
const initMap = L.map(mapRef.current, {
|
||||
center: [53.111111, 8.4625],
|
||||
zoom: 12,
|
||||
layers: [layers.MAP_LAYERS.TALAS, layers.MAP_LAYERS.ECI, layers.MAP_LAYERS.ULAF, layers.MAP_LAYERS.GSMModem],
|
||||
layers: [
|
||||
layers.MAP_LAYERS.TALAS,
|
||||
layers.MAP_LAYERS.ECI,
|
||||
layers.MAP_LAYERS.GSMModem,
|
||||
layers.MAP_LAYERS.CiscoRouter,
|
||||
layers.MAP_LAYERS.WAGO,
|
||||
layers.MAP_LAYERS.Siemens,
|
||||
layers.MAP_LAYERS.OTDR,
|
||||
layers.MAP_LAYERS.WDM,
|
||||
layers.MAP_LAYERS.GMA,
|
||||
layers.MAP_LAYERS.TALASICL,
|
||||
layers.MAP_LAYERS.Sonstige,
|
||||
layers.MAP_LAYERS.ULAF,
|
||||
],
|
||||
minZoom: 5,
|
||||
maxZoom: 15,
|
||||
zoomControl: false,
|
||||
@@ -22,28 +35,27 @@ export const initializeMap = (mapRef, setMap, setOms, setMenuItemAdded, addItems
|
||||
text: "Station öffnen (Tab)",
|
||||
icon: "/img/screen_new.png",
|
||||
callback: (e) => {
|
||||
const link = localStorage.getItem("polylineLink");
|
||||
const clickedElement = e.relatedTarget;
|
||||
|
||||
// Überprüfe, ob Karte und contextmenu existieren
|
||||
if (initMap && initMap.contextmenu) {
|
||||
// Verarbeite Kontextmenü-Callback
|
||||
if (link) {
|
||||
const newTab = window.open(link, "_blank");
|
||||
if (newTab) {
|
||||
// Lösche Einträge im localStorage
|
||||
localStorage.removeItem("polylineLink");
|
||||
localStorage.removeItem("lastElementType");
|
||||
if (!clickedElement) {
|
||||
console.error("No valid target for the context menu entry (Element is null).");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if (clickedElement instanceof L.Marker || clickedElement?.options?.link) {
|
||||
const link = clickedElement.options.link;
|
||||
if (link) {
|
||||
console.log("Opening link in a new tab:", link);
|
||||
window.open(link, "_blank");
|
||||
} else {
|
||||
console.error("Fehler: Das neue Tab konnte nicht geöffnet werden.");
|
||||
console.error("No link found in the Marker options.");
|
||||
}
|
||||
} else if (clickedElement instanceof L.Marker || clickedElement instanceof L.Polyline) {
|
||||
openInNewTab(e, clickedElement);
|
||||
} else {
|
||||
console.error("Kein gültiges Ziel für den Kontextmenüeintrag");
|
||||
console.error("No valid target for the context menu entry");
|
||||
}
|
||||
} else {
|
||||
console.error("Karte oder Kontextmenü nicht verfügbar.");
|
||||
} catch (error) {
|
||||
console.error("Error processing the context menu:", error);
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user