feat: Move openInSameWindow function to a separate file
- Moved the openInSameWindow function from MapComponent.js to a new file openInSameWindow.js in the utils directory. - Updated MapComponent.js to import and use the openInSameWindow function from the new file. - This change improves code modularity and readability.
This commit is contained in:
@@ -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);
|
||||
|
||||
10
utils/openInSameWindow.js
Normal file
10
utils/openInSameWindow.js
Normal file
@@ -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");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user