38 lines
1.1 KiB
JavaScript
38 lines
1.1 KiB
JavaScript
import { useEffect, useState } from "react";
|
|
import L from "leaflet";
|
|
import { addContextMenuToMarker } from "../utils/contextMenuUtils";
|
|
import { createAndSetMarkers } from "../utils/markerUtils";
|
|
|
|
const useMessstellenMarkersLayer = (map, oms, GisSystemStatic, priorityConfig) => {
|
|
const [messstellenMarkers, setMessstellenMarkers] = useState([]);
|
|
|
|
useEffect(() => {
|
|
if (GisSystemStatic && GisSystemStatic.length && map) {
|
|
createAndSetMarkers(13, setMessstellenMarkers, GisSystemStatic, priorityConfig); // Messstellen
|
|
}
|
|
}, [GisSystemStatic, map, priorityConfig]);
|
|
|
|
useEffect(() => {
|
|
if (map && messstellenMarkers.length) {
|
|
messstellenMarkers.forEach((marker) => {
|
|
marker.addTo(map);
|
|
oms.addMarker(marker);
|
|
|
|
// Popup on mouseover and mouseout
|
|
marker.on("mouseover", function () {
|
|
this.openPopup();
|
|
});
|
|
marker.on("mouseout", function () {
|
|
this.closePopup();
|
|
});
|
|
|
|
addContextMenuToMarker(marker);
|
|
});
|
|
}
|
|
}, [map, messstellenMarkers, oms]);
|
|
|
|
return messstellenMarkers;
|
|
};
|
|
|
|
export default useMessstellenMarkersLayer;
|