1
I’m trying to make each marker in this loop have an infowindow with different content, the arrays are the same size and are being taken from the database, the problem is that by creating new infowindow instead it just replaces the content of the old one, that is, although each point opens an independent infowindow all have the same content of the last item of the arrayName[]
function AtivaMarkers(){
for(i in arrayLat){
var infowindow = new google.maps.InfoWindow({
content: arrayNome[i]
});
var local = new google.maps.LatLng(arrayLat[i],arrayLng[i]);
var marcador = new google.maps.Marker({
title: arrayNome[i],
position: local,
icon: "http://maps.google.com/mapfiles/kml/paddle/grn-circle.png",
map: map
}); marcador.addListener('click', function() {
infowindow.open(map,this);
});
markers.push(marcador);
}
}
I wonder if there are ways to make a different infowindow for each marker by loop, since at each moment the size of the arrays can change so I can’t attach to a fixed number of infowindow.