Pregunta

$(document).on 'click', '#sideBar li', ->
    markers[$(this).data('marker')].panTo()
    google.maps.event.trigger(markers[$(this).data('marker')], 'click')

Seems silly. All answers point to this working perfectly. My map pans to the appropriate marker, but I can't seem to get the 'click' action to happen to open the infowindow. I'm using the new v2 of the gmaps4rails gem, which is where the .panTo() comes from.

Since it pans just fine, I'm inclined to believe that my markers[$(this).data('marker')] marker call is fine.

answer 1 answer 2

¿Fue útil?

Solución

Actually the marker js object is a wrapper around the real google marker.

This enables to add extra methods.

If you need access to the google marker, just call getServiceObject function method.

This is what you need:

googleMarker = markers[$(this).data('marker')].getServiceObject()
google.maps.event.trigger(googleMarker, 'click')
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top