POIs hinzufügen, löschen und bearbeiten funktioniert! in mapFeatures.js als marker, irgendwann in poi umbenennen

This commit is contained in:
ISA
2024-08-15 15:53:27 +02:00
parent 18ad7cad7e
commit 8699c1c4a0
10 changed files with 121 additions and 103 deletions

View File

@@ -1,33 +1,40 @@
// contextMenuUtils.js
import { BASE_URL } from "../config/urls";
export function addContextMenuToMarker(marker) {
marker.unbindContextMenu(); // Entferne das Kontextmenü, um Duplikate zu vermeiden
marker.bindContextMenu({
contextmenu: true,
contextmenuWidth: 140,
contextmenuItems: [
/* {
text: "Station öffnen (Tab)",
icon: "/img/screen_new.png",
callback: (e) => openInNewTab(e, marker),
},
{
text: "Station öffnen",
icon: "/img/screen_same.png",
callback: (e) => openInSameWindow(e, marker),
}, */
],
contextmenuItems: [],
});
}
// Funktion zum Öffnen in einem neuen Tab
export function openInNewTab(e, marker) {
export function openInNewTab(e, target) {
const baseUrl = BASE_URL;
//console.log("baseUrl:", baseUrl);
if (marker && marker.options && marker.options.link) {
//console.log("Marker data:", baseUrl + marker.options.link);
window.open(baseUrl + marker.options.link, "_blank");
let idLD, idModul, link;
if (target instanceof L.Polyline) {
idLD = target.options.idLD;
idModul = target.options.idModul;
if (idLD) {
link = `${baseUrl}/talas5/devices/cpl.aspx?id=${idLD}`;
if (idModul) {
//link += `&module=${idModul}`;
}
} else {
console.error("Keine gültige 'idLD' für die Linie gefunden.");
return;
}
} else if (target instanceof L.Marker && target.options.link) {
link = baseUrl + target.options.link;
} else {
console.error("Fehler: Marker hat keine gültige 'link' Eigenschaft");
console.error("Fehler: Ungültiges Ziel oder keine gültige 'link' Eigenschaft.");
return;
}
// Öffne den Link in einem neuen Tab
window.open(link, "_blank");
}