react-native-clusterer icon indicating copy to clipboard operation
react-native-clusterer copied to clipboard

Flickering when zooming

Open NiccoloCase opened this issue 1 year ago • 2 comments

https://github.com/JiriHoffmann/react-native-clusterer/assets/41541220/f57957ef-602b-4836-b344-202588c0ddd5

I noticed that the markers used for the cluster glitch when zooming in or out. I believe this is due to a change in the cluster id, which therefore forces a re render, also because I cannot therefore take advantage of the benefits of react.memo. Why this strange behavior of the cluster id? and how to avoid the problem?

NiccoloCase avatar May 03 '24 13:05 NiccoloCase

Can you provide a code example where the ids change?

JiriHoffmann avatar Jun 02 '24 22:06 JiriHoffmann

I came across the same issue. The cluster_id kept changing with different zoom levels, but stable while just moving the map, even if the cluster marker was memoized. As far as I understand supercluster, this is the intended algorithm - the zoom level is encoded in the cluster id. Which makes sense to me.

Now, I'm not sure if this is the correct way, but it seems to work if I use item.geometry.coordinates[0], item.geometry.coordinates[1] and item.properties.point_count instead of the cluster id for the memo keys as well as the cluster marker key.

daniel-xyz avatar Jan 16 '25 10:01 daniel-xyz