You created marker event listener
google.maps.event.addListener(marker, "click", function (cluster) {
console.log("Marker click");
});
outside of for
loop. So, the last marker created has event listener, others no.
This should work:
for (loc in locations) {
var latLng = new google.maps.LatLng(locations[loc].lat, locations[loc].lng);
var marker = new google.maps.Marker({
position: latLng
});
markers.push(marker);
google.maps.event.addListener(marker, "click", function (cluster) {
console.log("Marker click");
});
}