Search code examples
ruby-on-railsrubyruby-on-rails-3google-mapsgmaps4rails

Rails 3 gmaps4rails (clicking on the map)


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


Solution

  • 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.");
      });
    };