react-google-maps-api
react-google-maps-api copied to clipboard
Issues with clustering markers and pinch zoom on mobile
Problem We have noticed an intermittent bug on mobile when pinching to zoom. If a finger is on a cluster when pinching the map will occasionally zoom out to the full world map. On some devices we have found that this will happen 1 time in 20 tries.
We have been able to reproduce the bug on sites using the library Shipwrecks.cc. It appears that ~12% of our mobile users are experiencing this bug at least once in a session, which means we will have to drop our usage if it isn't fixed.
Suggested fix Looking at other cluster libraries they have had similar issues and found fixes:
- js-markerclustererplus main thread on the issue https://github.com/googlemaps/js-markerclustererplus/issues/76
- Solution https://github.com/googlemaps/v3-utility-library/blob/66d4921aba3c0d5aa24d5998e485f46c34a6db27/markerclustererplus/src/markerclusterer.js#L754-L770
Looking at the listeners they could be causing the problem.
Do you have capacity to fix this bug?
Please switch to @googlemaps/markerclusterer which doesn't have these issues.
released 2.6.0 - please test
For those who for whatever reason still use an older version. The error is caused by removing the cluster child (div_) in the onRemove function.
I have temporarily commented out this line so that the error is fixed and am currently working on a workaround. A simple timeout should also fix the problem or a dragend listener.
ClusterIcon.prototype.onRemove = function () { if (this.div_ && this.div_.parentNode) { this.hide(); // this.div_.parentNode.removeChild(this.div_); <-------- this line causes the problem this.div_ = null; } };
I hope I could help. It took a little while to find the problem.
@Jasper992 your PR is welcome!