Station öffnen (Tab) für polylines ok, aber für marker muss noch option.link nehmen

This commit is contained in:
ISA
2024-09-02 15:58:42 +02:00
parent 9724c886b2
commit 17a8075d73
3 changed files with 55 additions and 120 deletions

View File

@@ -1,18 +1,15 @@
// /utils/mapInitialization.js
import L from "leaflet";
//import OverlappingMarkerSpiderfier from "overlapping-marker-spiderfier-leaflet";
import "leaflet-contextmenu";
import "leaflet/dist/leaflet.css";
import "leaflet-contextmenu/dist/leaflet.contextmenu.css";
import * as urls from "../config/urls.js";
import * as layers from "../config/layers.js";
import { addContextMenuToMarker, openInNewTab } from "../utils/contextMenuUtils.js";
import { addContextMenuToMarker, openInNewTab } from "../utils/contextMenuUtils";
export const initializeMap = (mapRef, setMap, setOms, setMenuItemAdded, addItemsToMapContextMenu, hasRights) => {
const offlineTileLayer = urls.OFFLINE_TILE_LAYER;
//const offlineTileLayer = process.env.OFFLINE_TILE_LAYER;
const onlineTileLayer = urls.ONLINE_TILE_LAYER;
//const onlineTileLayer = process.env.ONLINE_TILE_LAYER;
const TALAS = layers.MAP_LAYERS.TALAS;
const ECI = layers.MAP_LAYERS.ECI;
const ULAF = layers.MAP_LAYERS.ULAF;
@@ -40,8 +37,20 @@ export const initializeMap = (mapRef, setMap, setOms, setMenuItemAdded, addItems
text: "Station öffnen (Tab)",
icon: "/img/screen_new.png",
callback: (e) => {
const clickedMarker = e.relatedTarget;
openInNewTab(e, clickedMarker);
const lastElementType = localStorage.getItem("lastElementType");
if (lastElementType === "polyline") {
const storedLink = localStorage.getItem("polylineLink");
if (storedLink) {
console.log("Opening polyline link:", storedLink);
window.open(storedLink, "_blank");
}
} else if (lastElementType === "marker") {
const clickedItem = e.relatedTarget;
if (clickedItem instanceof L.Marker) {
openInNewTab(e, clickedItem);
}
}
},
},
"-",