20 lines
610 B
TypeScript
20 lines
610 B
TypeScript
import { useEffect } from "react";
|
|
import type VectorLayer from "ol/layer/Vector";
|
|
import type VectorSource from "ol/source/Vector";
|
|
|
|
/**
|
|
* Hook that controls the opacity of the capitals layer depending on the selected district.
|
|
*
|
|
* @param capitalsLayer - The OpenLayers VectorLayer instance for capitals.
|
|
* @param value - Value to observe, boolean.
|
|
*/
|
|
export function useCapitals(
|
|
capitalsLayer: VectorLayer<VectorSource<any>> | null,
|
|
value: boolean
|
|
) {
|
|
useEffect(() => {
|
|
if (!capitalsLayer) return;
|
|
|
|
capitalsLayer.setOpacity(value ? 0 : 1);
|
|
}, [capitalsLayer, value]);
|
|
} |