import { useContext, useEffect } from 'react';
import MapContext from '../Map/MapContext';
import OLVectorLayer from 'ol/layer/Vector';
export const VectorLayer = ({ source, style, zIndex = 0 }) => {
    const { map } = useContext(MapContext);
    useEffect(() => {
        if (!map)
            return;
        const vectorLayer = new OLVectorLayer({
            source,
            style
        });
        map.addLayer(vectorLayer);
        vectorLayer.setZIndex(zIndex);
        return () => {
            if (map) {
                map.removeLayer(vectorLayer);
            }
        };
    }, [map, source]);
    return null;
};
//# sourceMappingURL=VectorLayer.js.map