jawj / OverlappingMarkerSpiderfier

Deals with overlapping markers in Google Maps JS API v3, Google Earth-style
http://blog.mackerron.com
836 stars 238 forks source link

Preventing event propagation / exposing spiderfying click #158

Open BHare1985 opened 6 years ago

BHare1985 commented 6 years ago

I am using trackMarker / addMarker to use the spider_click event. Within it I stop event propogation as such:

self.oms.addMarker(marker, function() {
    // do some stuff
    event.stopPropagation();
});

This works as I want it, clicks do not go to my overlays in google maps when clicking on a marker that wont spidify and also once markers get spidify, clicking on them doesnt propogate.

The issue however is the event that causes the spidify to happen still allows event propogation. I solved this by preventing it on all marker clicks:

google.maps.event.addListener(marker, "click", function() {
    event.stopPropagation();
});

Although I am not happen with this solution because I wasnt sure it would even work and also it requires me to do additional listener.

It would be super useful if this was handled natively by OMS, perhaps by some sort of setting to never propogate events. Alternatively, I couldnt find an event for spidering_click that is, the click that will cause a spidering but not an actual spider_click. I tried to recreate this by listening to all clicks and then determining if the marker was would spidery, if it would then i know it was a spidering_click , but this seems better handled by OMS to expose