googlearchive / js-marker-clusterer

A marker clustering library for the Google Maps JavaScript API v3.
https://googlemaps.github.io/js-marker-clusterer/docs/reference.html
Apache License 2.0
1.28k stars 772 forks source link

Clicking on cluster icon in Google Chrome not working #87

Open stevesuk opened 8 years ago

stevesuk commented 8 years ago

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"?

jandrodev commented 8 years ago

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

alexalexalex-s commented 8 years ago

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; });

RayofNogg commented 7 years ago

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.

nawara28 commented 7 years ago

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.

aesculus commented 7 years ago

@alexalexalex-s

Thank you so much for this.