I had the exact same question and here is my (partial) solution:
Assuming you've set up your rails app like is shown on the youtube video (linked to on the github page https://github.com/apneadiving/Google-Maps-for-Rails).
Add marker.json({ :id => location.id }) to your controller so it ends up like this:
@hash = Gmaps4rails.build_markers(@locations) do |location, marker|
marker.lat location.latitude
marker.lng location.longitude
marker.infowindow "$#{location.suggested_price}, #{location.address}"
marker.json({ :id => location.id })
end
then, in your view under the javascript to build a map, add a .each function that goes through each piece of json and adds functionality to its corresponding class in your view (I'm assuming you're wrapping each of your sidebar items with a div called "location-<%= location.id %>":
handler = Gmaps.build('Google', { markers: { maxRandomDistance: null } });
handler.buildMap({ provider: {}, internal: {id: 'map'}}, function(){
markers = handler.addMarkers(<%=raw @hash.to_json %>);
_.each(<%=raw @hash.to_json %>, function(json, index){
json.marker = markers[index];
$(".location-" + json.id).on('mouseover', function() {
handler.getMap().setZoom(14);
json.marker.setMap(handler.getMap()); //because clusterer removes map property from marker
json.marker.panTo();
google.maps.event.trigger(json.marker.getServiceObject(), 'click');
});
});
handler.bounds.extendWith(markers);
handler.fitMapToBounds();
handler.getMap().setCenter(new google.maps.LatLng(<%= @city.latitude %>, <%= @city.longitude %>));
handler.getMap().setZoom(14);
});
I stole this from one of apneadiving's examples (and just removed all the pretty refactoring).
Now, in my example, instead of changing the color of the marker, I'm centering the map over the corresponding marker and opening up the infowindow. All you have to do is change the code in the function to whatever behavior you want, replacing this part:
handler.getMap().setZoom(14);
json.marker.setMap(handler.getMap()); //because clusterer removes map property from marker
json.marker.panTo();
google.maps.event.trigger(json.marker.getServiceObject(), 'click');
Hope that helps!