# Ym4r\_gm plugin marker\_group question

**URL:** <https://www.ruby-forum.com/t/ym4r-gm-plugin-marker-group-question/127440>\
**Category:** Rails\
**Created:** [January 29, 2008, 7:04am UTC](https://www.ruby-forum.com/t/ym4r-gm-plugin-marker-group-question/127440 "2008-01-29T07:04:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bucks](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/cab0a1/32.png) [@bucks](https://www.ruby-forum.com/u/bucks)\
**Post date:** [January 29, 2008, 7:04am UTC](https://www.ruby-forum.com/t/ym4r-gm-plugin-marker-group-question/127440/1 "2008-01-29T07:04:47Z")

</div>

Hello,  
I am using the ym4r\_gm plugin with rails, and I am trying to use the  
marker group feature. The main functionality I am trying to develop is  
summed up by the following point from the ym4r\_gm documentation.

Marker groups can be used for:

- Keeping an index of markers, for example, in order to show one of  
these markers in reponse to a click on a link (the way Google Local  
does with the results of the search).

My initial page load, which plots the first set of markers on the map  
works fine with the marker group. However, when I update the map via  
ajax, the new markers are re-plotted, but it seems the marker\_group is  
lost, as I can no longer click on the links to show the marker on the  
map.

Does anyone have an idea of why I am loosing the ability to click on  
my link to show the marker pop-up on the map?

Below is the code I am using:

#first controller function that is called  
def initialize\_map  
@map = GMap.new(“map\_div”)  
@map.control\_init(:large\_map =\> true,:map\_type =\> true)  
@map.interface\_init({ :dragging =\> true, :info\_window=\>  
true, :double\_click\_zoom =\> true, :scroll\_wheel\_zoom =\> true })  
plot\_points\_on\_map(find\_points)  
end

def plot\_points\_on\_map(@points)  
@markers = Hash.new  
for point in @points  
marker = GMarker.new(point.address, :title =\>  
“geocoded”, :info\_window =\> point.name, :icon =\> :icon\_point)  
@markers[point.id] = marker  
end  
@marker\_group = GMarkerGroup.new(true, @markers)  
@map.overlay\_global\_init(@marker\_group, “markerGroup”)  
end

Then in my partial \_results.rhtml I have the following anchor  
\<% for point in @points %\>  
View on map  
\<% end -%\>

I have a form with various controls, that call the following when  
submitted via ajax

def update\_points\_using\_criteria  
@points = find\_points  
@map = Variable.new(“map”)  
plot\_points\_on\_map(@points)  
end  
end

And the corresponding rjs file

page \<\< @map.clear\_overlays  
@markers.each\_pair {|point\_id, marker|  
page \<\< @map.add\_overlay(marker)  
}  
page.replace\_html ‘results-wide’, :partial =\> ‘results’
