googlearchive/js-marker-clusterer

Clicking on cluster icon in Google Chrome not working

stevesuk opened this issue · 5 comments

With the latest version of Google Chrome, clicking on a cluster icon has no affect. I believe this is down to a recent change that is meant to prevent the cluster click event from firing if a drag is taking place. To demonstrate the problem, check out the maps on the examples page.

Commenting out...

if (!isDragging) { that.triggerClusterClick(event); }

And just replacing it with:

that.triggerClusterClick(event);

Fixes the issue. I guess there may be a problem with the code that sets "isDragging"?

Thanks man !!! I was going crazy with this. What he says fixes the problem.

By just commenting out !isDragging you introduce a usability issue whereby dragging the map while the mouse is over a cluster icon will zoom in once you finish the drag, just like if you've clicked it.

Here is a simpler fix I've implemented which fixes the issue in Chrome and allows dragging to behave as expected. Remove the existing mousedown and mousemove events on this.div_ and replace with this:

google.maps.event.addDomListener(this.div_, 'mousedown', function () { google.maps.event.addListenerOnce(that.map_, "dragstart", function () { isDragging = true; }); isDragging = false; });

I also had this problem and stevesuk's solution fixed the problem just short of me resorting to fits of violence. Thanks man!
alexanderschana's works too!
Thanks guys.

For IONIC users' sake I am adding my fixes.

In mobile there is no 'mousedown' or 'mousemove' event defined so I use 'dragstart', 'dragend' envent instead.

google.maps.event.addListenerOnce(that.map_, "dragstart", function () { isDragging = true; });
google.maps.event.addListenerOnce(that.map_, "dragend", function () { isDragging = false; });

This solves my marker-cluster-not-clicking problem in some devices.

@alexalexalex-s

Thank you so much for this.