react-google-maps-api icon indicating copy to clipboard operation
react-google-maps-api copied to clipboard

Issues with clustering markers and pinch zoom on mobile

Open chard234 opened this issue 3 years ago • 4 comments

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?

chard234 avatar Sep 24 '21 15:09 chard234

Please switch to @googlemaps/markerclusterer which doesn't have these issues.

jpoehnelt avatar Nov 03 '21 06:11 jpoehnelt

released 2.6.0 - please test

JustFly1984 avatar Nov 08 '21 22:11 JustFly1984

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 avatar Feb 20 '22 21:02 Jasper992

@Jasper992 your PR is welcome!

JustFly1984 avatar Feb 21 '22 20:02 JustFly1984