mit rechte Maustaste auf ein Gerät disablePolylineEvents(window.polylines);, muss noch angepasst werden
This commit is contained in:
@@ -1,10 +1,10 @@
|
|||||||
// /utils/createAndSetDevices.js
|
|
||||||
import circleIcon from "../components/gisPolylines/icons/CircleIcon";
|
import circleIcon from "../components/gisPolylines/icons/CircleIcon";
|
||||||
import { saveLineData, redrawPolyline } from "./mapUtils";
|
import { saveLineData, redrawPolyline } from "./mapUtils";
|
||||||
import L from "leaflet";
|
import L from "leaflet";
|
||||||
import "leaflet.smooth_marker_bouncing";
|
import "leaflet.smooth_marker_bouncing";
|
||||||
import { toast } from "react-toastify";
|
import { toast } from "react-toastify";
|
||||||
import * as config from "../config/config.js";
|
import * as config from "../config/config.js";
|
||||||
|
import { disablePolylineEvents, enablePolylineEvents } from "./setupPolylines"; // Importiere die Funktion zum Deaktivieren der Polyline-Ereignisse
|
||||||
|
|
||||||
// Funktion zum Bestimmen der Priorität basierend auf dem Icon-Pfad
|
// Funktion zum Bestimmen der Priorität basierend auf dem Icon-Pfad
|
||||||
const determinePriority = (iconPath, priorityConfig) => {
|
const determinePriority = (iconPath, priorityConfig) => {
|
||||||
@@ -29,16 +29,11 @@ export const createAndSetDevices = async (systemId, setMarkersFunction, GisSyste
|
|||||||
if (jsonResponse.Points && statusResponse.Statis) {
|
if (jsonResponse.Points && statusResponse.Statis) {
|
||||||
const statisMap = new Map(statusResponse.Statis.map((s) => [s.IdLD, s]));
|
const statisMap = new Map(statusResponse.Statis.map((s) => [s.IdLD, s]));
|
||||||
let markersData = jsonResponse.Points.filter((station) => station.System === systemId && getIdSystemAndAllowValueMap.get(station.System) === 1).map((station) => {
|
let markersData = jsonResponse.Points.filter((station) => station.System === systemId && getIdSystemAndAllowValueMap.get(station.System) === 1).map((station) => {
|
||||||
//console.log("Station: ", station);
|
|
||||||
const statis = statisMap.get(station.IdLD);
|
const statis = statisMap.get(station.IdLD);
|
||||||
//console.log("Statis: ", statis);
|
|
||||||
const iconPath = statis ? `img/icons/${statis.Na}-marker-icon-${station.Icon}.png` : `img/icons/marker-icon-${station.Icon}.png`;
|
const iconPath = statis ? `img/icons/${statis.Na}-marker-icon-${station.Icon}.png` : `img/icons/marker-icon-${station.Icon}.png`;
|
||||||
|
|
||||||
const priority = determinePriority(iconPath, priorityConfig);
|
const priority = determinePriority(iconPath, priorityConfig);
|
||||||
//console.log("Priority: ", priority);
|
|
||||||
//console.log("statis.Le: ", statis.Le);
|
|
||||||
const zIndexOffset = 100 * (5 - priority); // Adjusted for simplicity and positive values
|
const zIndexOffset = 100 * (5 - priority); // Adjusted for simplicity and positive values
|
||||||
//console.log("Z-Index Offset: ", zIndexOffset);
|
|
||||||
|
|
||||||
const marker = L.marker([station.X, station.Y], {
|
const marker = L.marker([station.X, station.Y], {
|
||||||
icon: L.icon({
|
icon: L.icon({
|
||||||
@@ -52,11 +47,27 @@ export const createAndSetDevices = async (systemId, setMarkersFunction, GisSyste
|
|||||||
zIndexOffset: zIndexOffset,
|
zIndexOffset: zIndexOffset,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Deaktiviere Polyline-Ereignisse beim Überfahren des Markers
|
||||||
|
marker.on("mouseover", function () {
|
||||||
|
this.openPopup();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Verwende das `contextmenu`-Ereignis für den Rechtsklick
|
||||||
|
marker.on("contextmenu", function (event) {
|
||||||
|
if (event && event.preventDefault) {
|
||||||
|
event.preventDefault(); // Verhindert das Standard-Kontextmenü
|
||||||
|
}
|
||||||
|
disablePolylineEvents(window.polylines);
|
||||||
|
this.openPopup();
|
||||||
|
});
|
||||||
|
|
||||||
|
marker.on("mouseout", function () {
|
||||||
|
this.closePopup();
|
||||||
|
});
|
||||||
|
|
||||||
// Überprüfe, ob die bounce-Funktion verfügbar ist und verwende sie
|
// Überprüfe, ob die bounce-Funktion verfügbar ist und verwende sie
|
||||||
if (typeof marker.bounce === "function" && statis) {
|
if (typeof marker.bounce === "function" && statis) {
|
||||||
marker.on("add", () => marker.bounce(3));
|
marker.on("add", () => marker.bounce(3));
|
||||||
} else if (statis) {
|
|
||||||
//console.error("Bounce function is not available on marker");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const statusInfo = statusResponse.Statis.filter((status) => status.IdLD === station.IdLD)
|
const statusInfo = statusResponse.Statis.filter((status) => status.IdLD === station.IdLD)
|
||||||
@@ -87,6 +98,6 @@ export const createAndSetDevices = async (systemId, setMarkersFunction, GisSyste
|
|||||||
setMarkersFunction(markersData);
|
setMarkersFunction(markersData);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
//console.error("Error fetching data: ", error);
|
console.error("Error fetching data: ", error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user