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 { MAP_VERSION } from "../config/settings";
|
||||||
import * as layers from "../config/layers.js";
|
import * as layers from "../config/layers.js";
|
||||||
import useMapContextMenu from "./useMapContextMenu.js";
|
import useMapContextMenu from "./useMapContextMenu.js";
|
||||||
|
import { openInSameWindow } from "../utils/openInSameWindow";
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
//-------------------- MapComponent -----------------------------------
|
//-------------------- MapComponent -----------------------------------
|
||||||
const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||||
@@ -235,16 +235,6 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
|||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
//-----Kontextmenu----------------
|
//-----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) => {
|
const zoomIn = (e) => {
|
||||||
initMap.flyTo(e.latlng, 12);
|
initMap.flyTo(e.latlng, 12);
|
||||||
//console.log("ZoomIn koordinaten in MapComponent", e.latlng);
|
//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