Skip to content

Conversation

ronlv10
Copy link
Contributor

@ronlv10 ronlv10 commented Jul 28, 2025

Summary

This PR updates the custom-marker-clustering example to delay cluster rendering until the map becomes idle, rather than reacting to every bounds_changed event during zoom.

Motivation

While investigating issue #563, I found that the aggressive re-clustering during zoom gestures may contribute to a rare but severe bug where the zoom level resets unexpectedly (sometimes to zero). This is especially noticeable with a large number of markers. See comment.

By aligning the behavior with how Google’s official [js-markerclusterer](https://github.com/googlemaps/js-markerclusterer)(https://github.com/googlemaps/js-markerclusterer) handles clustering (listening to the idle event), we reduce the likelihood of triggering this issue and improve performance during zoom gestures.

@usefulthink
Copy link
Collaborator

That seems reasonable.
Although the clustering (or rather, retrieving the clusters) is pretty fast, it makes total sense to debounce that a bit, and waiting for the idle event is a great way to do that.

@usefulthink
Copy link
Collaborator

Let me know if we should merge this. It sounds like you're still investigating other things regarding the now infamous #563 issue.

@ronlv10
Copy link
Contributor Author

ronlv10 commented Jul 28, 2025

I think you can merge. I don't investigate it more as I proved that it comes from google maps js

@usefulthink usefulthink merged commit bed6ccd into visgl:main Jul 28, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants