Remove Gmap marker using YM4R

Hello,
I'm using http://ym4r.rubyforge.org and I have a problem with removing
existing marker. I tried this (.rjs file):
[code]
if @params[:gobject] == "on"
  @gobject_results.each {|marker| page << @map.addOverlay(marker)}
else
  @gobject_results.each {|marker| page << @map.removeOverlay(marker)}
end
[/code]
but it doesn't work (I mean it only adds marks). I read on google maps
API forums, that I need to have array of marks which was added, to
remove them later.
Please help me write this .js code in .rjs file:
[code]
var MarkersArray = []; // global

var marker = new GMarker(PointsArray[Counter]);
// Adding:
map.addOverlay(marker);
MarkersArray[Counter] = marker;

// So I can remove a marker with:
map.removeOverlay(MarkersArray[Counter]);
[/code]

Thank you in advance,
Stan