From eric.lubow at gmail.com Sat Feb 20 14:53:11 2010 From: eric.lubow at gmail.com (Eric Lubow) Date: Sat, 20 Feb 2010 14:53:11 -0500 Subject: [Ym4r-user] Clustering Issues With Google Maps Message-ID: <91882eb1002201153h508ec649i8b938b2a7ea8a5ab@mail.gmail.com> There seems to be very little documentation about Clustering with Google Maps and Ym4r. I will happily write a HOWTO once I figure this out. Anyway, here is my question (I already asked it on StackOverflow to no avail and it can be referenced here): http://stackoverflow.com/questions/2278778/google-maps-cluster-not-working-with-ym4r-gm Onto the question... I am attempting to get a Google Maps cluster working with ym4r_gm for Rails. I know the general code works because every point is being displayed on the map. The problem is that every point is being displayed on the map. I only have like 350 points (right now) so its not too bad without clustering, but I would like to have it working so that I can scale. Relevant controller code: def bizmap @map = GMap.new( "map" ) @map.control_init( :large_map => true, :map_type => true ) @map.center_zoom_init( [ 40.228,-100.283 ], 1 ) markers = Array.new Business.find(:all, :include => [:addresses], :conditions => ["addresses.website_only != 1"]).each do |biz| if (!biz.addresses.first.latitude.blank? and !biz.addresses.first.longitude.blank?) markers.push( GMarker.new( [biz.addresses.first.latitude,biz.addresses.first.longitude], :title => biz.name, :info_window => pretty_info_window( biz.name, biz.addresses.first ) ) ) end end clusterer = Clusterer.new(markers, :min_markers_per_cluster => 2) @map.overlay_init(clusterer) end Relevant view code:
<%= GMap.header %> <%= javascript_include_tag 'clusterer' %> <%= @map.to_html %> <%= @map.div(:width => 600, :height => 400) %>
The relevant code generated by the view is here: Thanks in advance for any help. -e -- Eric Lubow w: eric.lubow.org -------------- next part -------------- An HTML attachment was scrubbed... URL: