I faced a problem using a @googlemaps/markerclusterer and @vis.gl/react-google-maps libraries that I cant cluster only one marker no matter what approach I used. Right now clustering part looks like this:
useEffect(() => {
if (!map) return;
clusterer.current = new MarkerClusterer({
map,
markers: [],
algorithm: new SuperClusterAlgorithm({
minPoints: 1,
}),
});
return () => {
if (clusterer.current) {
clusterer.current.clearMarkers();
clusterer.current = null;
}
};
}, [map]);
const memoizedMarkers = useMemo(() => markers, [markers]);
useEffect(() => {
if (!clusterer.current || !map) return;
const markerElements = Object.values(markersRef.current);
clusterer.current.clearMarkers();
clusterer.current.addMarkers(markerElements);
}, [map, memoizedMarkers]);
Can someone help me please to find a way how to cluster only one marker.
I went to documentation and havent found the correct answer, I tried:
clusterer.current = new MarkerClusterer({
map,
markers: [],
algorithm: new SuperClusterAlgorithm({
minPoints: 2, // Changed from 1 to 2
}),
});
but it didnt work