0
我想将事件侦听器添加到所有标记,我正在使用Google-Maps-for-Rails创业板。这是我的代码Google地图将标记添加到侦听器
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()
我试图添加事件侦听器到所有标记,但它不会提醒任何事情。我怎么可以添加事件侦听器在谷歌地图的轨道
我有数据,其中每个数据包含ID,LAT的数组,LNG
您可以尝试查看关于Google Maps with Rails的[文档](https://www.sitepoint.com/use-google-maps-rails/)。它在本文档中介绍如何在标记中添加事件侦听器。因此,请查看示例代码,了解如何正确实现它。 – KENdi