Links für alle Geräte funktioniert aber für die Linien muss noch bearbeitet werden

This commit is contained in:
ISA
2024-09-04 09:01:09 +02:00
parent 466fc55025
commit 3c433b9003
2 changed files with 17 additions and 29 deletions

View File

@@ -1,10 +1,16 @@
// /utils/openInNewTab.js
import { BASE_URL } from "../config/urls";
export function openInNewTab(e, target) {
const BASE_URL = process.env.NEXT_PUBLIC_BASE_URL;
let link;
if (target instanceof L.Polyline) {
// Überprüfen, ob es sich um einen Marker handelt und ein gültiger Link vorhanden ist
if (target instanceof L.Marker && target.options.link) {
// Verwende den Link, der im Marker gespeichert ist
link = `${BASE_URL}${target.options.link}`;
//link = target.options.link;
} else if (target instanceof L.Polyline) {
// Polyline-Logik bleibt unverändert
const idLD = target.options.idLD;
if (idLD) {
link = `${BASE_URL}cpl.aspx?id=${idLD}`;
@@ -12,13 +18,15 @@ export function openInNewTab(e, target) {
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");
if (link) {
window.open(link, "_blank");
} else {
console.error("Fehler: Es wurde kein gültiger Link gefunden.");
}
}