diff --git a/components/MapComponent.js b/components/MapComponent.js index 6dee11000..70ed0b610 100644 --- a/components/MapComponent.js +++ b/components/MapComponent.js @@ -78,7 +78,7 @@ import { import { MAP_VERSION } from "../config/settings"; import * as layers from "../config/layers.js"; import useMapContextMenu from "./useMapContextMenu.js"; - +import { openInSameWindow } from "../utils/openInSameWindow"; //--------------------------------------------------------------------- //-------------------- MapComponent ----------------------------------- const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { @@ -235,16 +235,6 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { //---------------------------------------------------- //-----Kontextmenu---------------- - // Funktion zum Öffnen im gleichen Fenster - function openInSameWindow(e, marker) { - if (marker && marker.options && marker.options.link) { - //console.log("Marker data:", baseUrl + marker.options.link); - window.location.href = baseUrl + marker.options.link; - } else { - console.error("Fehler: Marker hat keine gültige 'link' Eigenschaft"); - } - } - const zoomIn = (e) => { initMap.flyTo(e.latlng, 12); //console.log("ZoomIn koordinaten in MapComponent", e.latlng); diff --git a/utils/openInSameWindow.js b/utils/openInSameWindow.js new file mode 100644 index 000000000..214c4719c --- /dev/null +++ b/utils/openInSameWindow.js @@ -0,0 +1,10 @@ +// utils/openInSameWindow.js + +export function openInSameWindow(e, marker, baseUrl) { + if (marker && marker.options && marker.options.link) { + //console.log("Marker data:", baseUrl + marker.options.link); + window.location.href = baseUrl + marker.options.link; + } else { + console.error("Fehler: Marker hat keine gültige 'link' Eigenschaft"); + } +}