Refactoring addContextMenuToMarker.js and openInNewTab.js
This commit is contained in:
24
utils/openInNewTab.js
Normal file
24
utils/openInNewTab.js
Normal 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");
|
||||
}
|
||||
Reference in New Issue
Block a user