0

I am on a rails v.3.1.11 app and using gmaps4rails gem. according to various examples I've seen, i tempt to doing the goal of the subject with this:

on the footer of my view (using haml):

= yield :scripts
:javascript
    Gmaps.map.callback = function(){
        console.log('callback');
        $(document).trigger('map:ready');
    }

then define the trigger on a coffee script file:

$(document).on 'map:ready', -> openInfoWindow()
openInfoWindow = ->
  for m in Gmaps.map.markers
    marker = m.serviceObject
    google.maps.event.addListener marker, "click" ->
      infowindow.open(map,marker)
    infowindow.open(map,marker)

but i have an error: Uncaught ReferenceError: object is not defined I made other attempts but I cannot figure out how to set the thing

easteregg
  • 149
  • 9
  • checkout this.. http://stackoverflow.com/questions/7774664/how-do-i-make-an-infowindow-automatically-display-as-open-with-google-maps-for-r – Kiran Apr 29 '13 at 05:17

1 Answers1

1

You can't use infowindow and map directly.

You have to use properties of the marker object(m in your code).

Try:

$(document).on 'map:ready', -> openInfoWindow()
openInfoWindow = ->
  for m in Gmaps.map.markers
    marker = m.serviceObject
    google.maps.event.addListener marker, "click" ->
      m.infowindow.open(marker.map, marker)
    m.infowindow.open(marker.map, marker)

hth

David
  • 1,161
  • 10
  • 17