48 lines
1.5 KiB
JavaScript
48 lines
1.5 KiB
JavaScript
import { useEffect, useState } from "react";
|
|
import L from "leaflet";
|
|
import { createAndSetDevices } from "../../utils/createAndSetDevices";
|
|
import { addContextMenuToMarker } from "../../utils/contextMenuUtils";
|
|
import { checkOverlappingMarkers } from "../../utils/mapUtils";
|
|
|
|
const useTalasMarkersLayer = (map, oms, GisSystemStatic, priorityConfig) => {
|
|
const [talasMarkers, setTalasMarkers] = useState([]);
|
|
|
|
useEffect(() => {
|
|
if (GisSystemStatic && GisSystemStatic.length && map) {
|
|
createAndSetDevices(1, setTalasMarkers, GisSystemStatic, priorityConfig); // TALAS-System
|
|
}
|
|
}, [GisSystemStatic, map, priorityConfig]);
|
|
|
|
useEffect(() => {
|
|
if (map && talasMarkers.length) {
|
|
talasMarkers.forEach((marker) => {
|
|
marker.addTo(map);
|
|
oms.addMarker(marker);
|
|
|
|
// Popup beim Überfahren mit der Maus öffnen und schließen
|
|
marker.on("mouseover", function () {
|
|
this.openPopup();
|
|
});
|
|
marker.on("mouseout", function () {
|
|
this.closePopup();
|
|
});
|
|
|
|
addContextMenuToMarker(marker);
|
|
});
|
|
// Disable map context menu
|
|
map.options.contextmenu = false;
|
|
map.options.contextmenuItems = [];
|
|
|
|
oms.map.options.contextmenu = false;
|
|
oms.map.options.contextmenuItems = [];
|
|
|
|
// Call the function to check for overlapping markers
|
|
checkOverlappingMarkers(oms, map);
|
|
}
|
|
}, [map, talasMarkers]);
|
|
|
|
return talasMarkers;
|
|
};
|
|
|
|
export default useTalasMarkersLayer;
|