Search code examples
google-mapsgoogle-maps-api-3gmaps4railsgmaps4rails2

Gmaps4Rails - How to refresh clusters?


I have an coffeescript function responsible for hiding/showing markers based on category passed as argument. Gmaps.markers variable has all markers loaded on map.

@displayMarkers = (category) ->
  i = 0
  while i < Gmaps.markers.length
    if Gmaps.markers[i].category is category
      Gmaps.markers[i].serviceObject.setVisible(true)
    else
      Gmaps.markers[i].serviceObject.setVisible(false)
    i++

How could I invoke MarkerClusterer.repaint() via JS?

Thanks!


Solution

  • the methods in gmaps4rails handle this by default when you add/remove:

    var marker = handler.addMarker(json);
    handler.removeMarker(marker)
    

    So I'd advise you to use them or to check their code