Take the 2-minute tour ×

Im trying to do a click on map that shows some info. Im using google API's

Gmaps4Rails.callback = function() {
google.maps.event.addListener(map, "click", function() {
alert("You clicked the map.");

but this is not working, It doesnt no anything

share|improve this question
@apneadiving never skips such questions :) –  fl00r Jul 18 '11 at 19:57
@fl00r: ;) Indeed: I feel like a father's duty regarding my gem :) –  apneadiving Jul 18 '11 at 20:00

1 Answer 1

up vote 4 down vote accepted

You're simply not getting the map object properly: it's stored in the Gmaps4Rails namespace:

Gmaps4Rails.callback = function() {
  google.maps.event.addListener(Gmaps4Rails.map, "click", function() {
    alert("You clicked the map.");
share|improve this answer
doesn't worked for me. is there any examples for this usage? –  Çağdaş Jul 3 '12 at 13:13
@Çağdaş: replace Gmaps4Rails.map with Gmaps.map.serviceObject –  apneadiving Jul 3 '12 at 16:10

Your Answer


