Search code examples
javascriptruby-on-railsgoogle-mapsgoogle-maps-api-3gmaps4rails

How to make infobox appear for marker with Google Maps For Rails?


I want to raise a click event on a marker so that the infobox will appear.

I am able to successfully do it with this:

$(marker.getServiceObject().content).click()

This however doesn't work on mobile. Not sure why.

I tried with a mousedown event, but this doesn't work either:

if $('html.no-touch').length
  $(m.getServiceObject().content).click()
else
  $(m.getServiceObject().content).mousedown()

I was thinking there was a more elegant solution of making the infobox appear.

If anyone has any suggestions, I'd greatly appreciate it. Thanks!


Solution

  • You must proceed this way:

     google.maps.event.trigger(m.getServiceObject(), 'click');