Here is a code of adding infoWindows and markers on google map:
infowindow = new google.maps.InfoWindow()
createMarker = (company)->
marker = new google.maps.Marker({
position: new google.maps.LatLng(company.latitude, company.longitude),
map: map,
title: company.name
})
google.maps.event.addListener(marker, 'click', ()->
content = 'some content'
infowindow.setContent(content)
infowindow.open(map,this)
)
createMarker(data[i]) for i in [0..data.length-1] by 1
I need to open first infoWindow automaticaly after page is loaded. How can I do it?
To fire an event:
google.maps.event.trigger(, ‘click’);
Now, you’ll need to store the references to the “marker” variables. Change
for
and add a last line: