apneadiving / Google-Maps-for-Rails

Enables easy Google map + overlays creation in Ruby apps
https://apneadiving.github.io/
MIT License
2.27k stars 382 forks source link

How to update clusters #502

Closed Rodrigora closed 8 years ago

Rodrigora commented 8 years ago

I've searched through google and StackOverlow and haven't find a solution for this:

How to refresh clusters after hiding (marker.setVisible(false)) some markers?

Thanks!

Rodrigora commented 8 years ago

Hi!

This is the solution I've used to show/hide markers when using a map with clusterer:

showHideMarker: (marker, visible) ->
  if visible
    if not marker.isVisible()
      marker.show()
      @handler.clusterer.addMarker(marker)
  else
    if marker.isVisible()
      marker.hide()
      @handler.clusterer.removeMarker(marker)

Hope it helps!