Refactoring addContextMenuToMarker.js and openInNewTab.js

This commit is contained in:
ISA
2024-09-04 08:41:18 +02:00
parent 5ed41642da
commit 466fc55025
25 changed files with 58 additions and 62 deletions

24
utils/openInNewTab.js Normal file
View File

@@ -0,0 +1,24 @@
// /utils/openInNewTab.js
import { BASE_URL } from "../config/urls";
export function openInNewTab(e, target) {
let link;
if (target instanceof L.Polyline) {
const idLD = target.options.idLD;
if (idLD) {
link = `${BASE_URL}cpl.aspx?id=${idLD}`;
} else {
console.error("Keine gültige 'idLD' für die Linie gefunden.");
return;
}
} else if (target instanceof L.Marker && target.options.link) {
link = BASE_URL + 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");
}