Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Commit

Permalink
fix: layer clusters do not updated correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
rot1024 committed Dec 17, 2021
1 parent 576ea46 commit ec74f66
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions src/components/molecules/Visualizer/Engine/Cesium/Cluster.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ export type Props = {
clusterImageHeight?: number;
clusterImageWidth?: number;
};
layers: {
layer?: string;
}[];
layers: { layer?: string }[];
};
pluginProperty?: { [key: string]: any };
isEditable?: boolean;
Expand Down Expand Up @@ -60,24 +58,19 @@ const Cluster: React.FC<Props> = ({
clusterImageHeight,
} = property?.default ?? {};

const cluster = useMemo<EntityCluster>(() => {
const cluster = useMemo(() => {
return new EntityCluster({
enabled: true,
pixelRange: 15,
minimumClusterSize: 3,
pixelRange: clusterPixelRange,
minimumClusterSize: clusterMinSize,
clusterBillboards: true,
clusterLabels: true,
clusterPoints: true,
});
}, []);
}, [clusterMinSize, clusterPixelRange]);

useEffect(() => {
cluster.pixelRange = clusterMinSize;
cluster.minimumClusterSize = clusterPixelRange;
}, [cluster, clusterMinSize, clusterPixelRange]);

useEffect(() => {
return cluster.clusterEvent.addEventListener((_clusteredEntities, clusterParam) => {
return cluster?.clusterEvent.addEventListener((_clusteredEntities, clusterParam) => {
clusterParam.label.font = toCSSFont(clusterLabelTypography, { fontSize: 30 });
clusterParam.label.horizontalOrigin =
clusterLabelTypography.textAlign === "right"
Expand All @@ -95,12 +88,13 @@ const Cluster: React.FC<Props> = ({
clusterParam.billboard.width = clusterImageHeight;
});
}, [
clusterMinSize,
clusterPixelRange,
cluster,
clusterLabelTypography,
clusterImage,
clusterImageHeight,
clusterImageWidth,
clusterLabelTypography,
property,
]);

return cluster ? (
Expand Down

0 comments on commit ec74f66

Please sign in to comment.