jawj / OverlappingMarkerSpiderfier

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

Spiderfy ony when map.getZoom() > X possible? #82

Closed metaxos closed 9 years ago

metaxos commented 9 years ago

Great work. We love it! It is possible to run your spiderfier only if the map has reached a certain zoom level?

jawj commented 9 years ago

Currently you'll have to hack this in, but it's not a hard job.

On line 141 of oms.coffee tack on an 'or' condition along the lines or @map.getZoom() < 12 — then recompile.

(Or you could do something equivalent to the compiled JS).

metaxos commented 9 years ago

Hi @jawj

Thank you. In my oms.coffee I have now: if markerSpiderfied or @map.getStreetView().getVisible() or @map.getMapTypeId() or @map.getZoom() > 12 this gives me in .js: if (markerSpiderfied || this.map.getStreetView().getVisible() || this.map.getMapTypeId() || (this.map.getZoom() > 12 && 12 === 'GoogleEarthAPI')) { return this.trigger('click', marker, event);

But the expected effect is not happening, the spiderfier is sill triggered on each zoomlevel. Do you have an idea? Should it not be a "and"?

thank you.

jawj commented 9 years ago

That JS is a bit weird and wrong, and it doesn't correspond to the CoffeeScript. It should be:

if (markerSpiderfied || this.map.getStreetView().getVisible() || this.map.getMapTypeId() === 'GoogleEarthAPI' || this.map.getZoom() < 12) ...

It should be an or (||) and the inequality should be the way round I specified before (less than rather than greater than) because it's a list of reasons why we should not spiderfy, but instead just pass the click straight through.

metaxos commented 9 years ago

Hi @jawj

Thank you. It works as whished :+1: Sorry, I should have gave me the espresso before!