I want to add event listener to all markers, i'm using Google-Maps-for-Rails gem. This is my code
markers_from_api = data.bookings
handler = Gmaps.build('Google')
settings = {
internal: {
id: 'multi_markers'
},
provider:{
styles: mapStyles
}
}
handler.buildMap settings, ->
markers = handler.addMarkers(markers_from_api)
_.each markers,(i, j) ->
google.maps.event.addListener i, 'click', (object) ->
alert 'hello'
return
createSidebar markers_from_api
createSidebarLi markers_from_api
handler.bounds.extendWith markers
handler.fitMapToBounds()
I tried to add event listener to all marker but it doesnt alert anything. How can i add event listeners in google maps for rails
I have an array of data, where each data contain id, lat, lng
Aucun commentaire:
Enregistrer un commentaire