36 lines
1.1 KiB
JavaScript
36 lines
1.1 KiB
JavaScript
import { useEffect, useState } from "react";
|
|
import { createAndSetDevices } from "../../utils/createAndSetDevices";
|
|
import { addContextMenuToMarker } from "../../utils/addContextMenuToMarker";
|
|
|
|
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 && oms) {
|
|
talasMarkers.forEach((marker) => {
|
|
oms.addMarker(marker); // Erst zu OMS hinzufügen
|
|
marker.addTo(map); // Dann zum Map hinzufügen
|
|
|
|
marker.on("mouseover", function () {
|
|
this.openPopup();
|
|
});
|
|
marker.on("mouseout", function () {
|
|
this.closePopup();
|
|
});
|
|
|
|
addContextMenuToMarker(marker); // Kontextmenü-Event hinzufügen
|
|
});
|
|
}
|
|
}, [map, talasMarkers, oms]);
|
|
|
|
return talasMarkers;
|
|
};
|
|
|
|
export default useTalasMarkersLayer;
|