feat: create /utils/contextMenuUtils.js module
This commit is contained in:
@@ -70,6 +70,10 @@ import {
|
|||||||
fetchUserRights,
|
fetchUserRights,
|
||||||
fetchDeviceNameById,
|
fetchDeviceNameById,
|
||||||
} from "../services/apiService.js";
|
} from "../services/apiService.js";
|
||||||
|
import {
|
||||||
|
addContextMenuToMarker,
|
||||||
|
openInNewTab,
|
||||||
|
} from "../utils/contextMenuUtils.js";
|
||||||
|
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
//-------------------- MapComponent -----------------------------------
|
//-------------------- MapComponent -----------------------------------
|
||||||
@@ -221,35 +225,6 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
|||||||
|
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
//-----Kontextmenu----------------
|
//-----Kontextmenu----------------
|
||||||
function addContextMenuToMarker(marker) {
|
|
||||||
marker.unbindContextMenu(); // Entferne das Kontextmenü, um Duplikate zu vermeiden
|
|
||||||
|
|
||||||
marker.bindContextMenu({
|
|
||||||
contextmenu: true,
|
|
||||||
contextmenuWidth: 140,
|
|
||||||
contextmenuItems: [
|
|
||||||
/* {
|
|
||||||
text: "Station öffnen (Tab)",
|
|
||||||
icon: "/img/screen_new.png",
|
|
||||||
callback: (e) => openInNewTab(e, marker),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: "Station öffnen",
|
|
||||||
icon: "/img/screen_same.png",
|
|
||||||
callback: (e) => openInSameWindow(e, marker),
|
|
||||||
}, */
|
|
||||||
],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
// Funktion zum Öffnen in einem neuen Tab
|
|
||||||
function openInNewTab(e, marker) {
|
|
||||||
if (marker && marker.options && marker.options.link) {
|
|
||||||
//console.log("Marker data:", baseUrl + marker.options.link);
|
|
||||||
window.open(baseUrl + marker.options.link, "_blank");
|
|
||||||
} else {
|
|
||||||
console.error("Fehler: Marker hat keine gültige 'link' Eigenschaft");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Funktion zum Öffnen im gleichen Fenster
|
// Funktion zum Öffnen im gleichen Fenster
|
||||||
function openInSameWindow(e, marker) {
|
function openInSameWindow(e, marker) {
|
||||||
|
|||||||
30
utils/contextMenuUtils.js
Normal file
30
utils/contextMenuUtils.js
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
// contextMenuUtils.js
|
||||||
|
export function addContextMenuToMarker(marker) {
|
||||||
|
marker.unbindContextMenu(); // Entferne das Kontextmenü, um Duplikate zu vermeiden
|
||||||
|
|
||||||
|
marker.bindContextMenu({
|
||||||
|
contextmenu: true,
|
||||||
|
contextmenuWidth: 140,
|
||||||
|
contextmenuItems: [
|
||||||
|
/* {
|
||||||
|
text: "Station öffnen (Tab)",
|
||||||
|
icon: "/img/screen_new.png",
|
||||||
|
callback: (e) => openInNewTab(e, marker),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: "Station öffnen",
|
||||||
|
icon: "/img/screen_same.png",
|
||||||
|
callback: (e) => openInSameWindow(e, marker),
|
||||||
|
}, */
|
||||||
|
],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// Funktion zum Öffnen in einem neuen Tab
|
||||||
|
export function openInNewTab(e, marker) {
|
||||||
|
if (marker && marker.options && marker.options.link) {
|
||||||
|
//console.log("Marker data:", baseUrl + marker.options.link);
|
||||||
|
window.open(baseUrl + marker.options.link, "_blank");
|
||||||
|
} else {
|
||||||
|
console.error("Fehler: Marker hat keine gültige 'link' Eigenschaft");
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user