41 lines
1.1 KiB
JavaScript
41 lines
1.1 KiB
JavaScript
// 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: [],
|
|
});
|
|
}
|
|
|
|
// Funktion zum Öffnen in einem neuen Tab
|
|
export function openInNewTab(e, target) {
|
|
const baseUrl = BASE_URL;
|
|
let idLD, idModul, link;
|
|
|
|
if (target instanceof L.Polyline) {
|
|
idLD = target.options.idLD;
|
|
idModul = target.options.idModul;
|
|
if (idLD) {
|
|
link = `${baseUrl}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: Ungültiges Ziel oder keine gültige 'link' Eigenschaft.");
|
|
return;
|
|
}
|
|
|
|
// Öffne den Link in einem neuen Tab
|
|
window.open(link, "_blank");
|
|
}
|