How to make an infowindow with different content for each marker in a loop

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 instead of creating new infowindow it just replaces the contents of the old, that is, although each point opens an independent infowindow all have the same content as 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 would like to know if there are ways to do a different infowindow for each marker in the loop, since every moment the size of the arrays can change so I can not bind to a fixed number of infowindow.

    
asked by anonymous 07.10.2017 / 22:21

0 answers