Skip to content

Commit 41f26f9

Browse files
committed
feat: add onPostRender vector layer
1 parent 225936b commit 41f26f9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/layers/vector-layer.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import { FunctionComponent, useContext, useEffect } from "react";
1+
import { FunctionComponent, useContext, useEffect, useState } from "react";
22
import { MapContext } from "../map/map-context";
33
import OLVectorLayer from "ol/layer/Vector";
44
import { Options } from "ol/layer/BaseVector";
55
import { BaseLayerProps } from "./base-layer-props";
66

77
interface VectorLayerProps {
88
onLayerChangeVisible?: (visible: boolean) => void;
9+
onPostRender?: () => void;
910
}
1011

1112
type Props = Options<any> & BaseLayerProps & VectorLayerProps;
@@ -15,6 +16,7 @@ const VectorLayer: FunctionComponent<Props> = ({
1516
zIndex = 0,
1617
name,
1718
onLayerChangeVisible,
19+
onPostRender,
1820
}) => {
1921
const map = useContext(MapContext);
2022

@@ -34,6 +36,10 @@ const VectorLayer: FunctionComponent<Props> = ({
3436
);
3537
}
3638

39+
if (onPostRender) {
40+
vectorLayer.on("postrender", (evt) => onPostRender());
41+
}
42+
3743
map.addLayer(vectorLayer);
3844
vectorLayer.setZIndex(zIndex);
3945

0 commit comments

Comments
 (0)