polylines tooltip content

This commit is contained in:
ISA
2024-08-10 10:32:37 +02:00
parent b1f7b700ca
commit b7116a1e6f
142 changed files with 14451 additions and 4281 deletions

26
hooks/useMarkerLayers.js Normal file
View File

@@ -0,0 +1,26 @@
// hooks/useMarkerLayers.js
import { useEffect } from "react";
import { useRecoilValue } from "recoil";
import { mapLayersState } from "../store/atoms/mapLayersState";
const useMarkerLayers = (map, markers, layerType) => {
const mapLayersVisibility = useRecoilValue(mapLayersState);
useEffect(() => {
if (!map || !markers) return;
const toggleLayer = (isVisible) => {
markers.forEach((marker) => {
if (isVisible) {
marker.addTo(map);
} else {
map.removeLayer(marker);
}
});
};
toggleLayer(mapLayersVisibility[layerType]);
}, [map, markers, mapLayersVisibility, layerType]);
};
export default useMarkerLayers;