I am trying to add separate info windows to multiple map markers in a mobile phone app with not much success. When I run my app and click any of the markers the same marker opens its infoWindow every time. Don't know where I have gone wrong.
result.users.forEach(function(entry){
latLng = new google.maps.LatLng(entry.user_lat, entry.user_lon);
marker.push(new google.maps.Marker({map: map, position: latLng}));
circle.push(new google.maps.Circle({map: map, radius: entry.user_accuracy, strokeWeight:1, strokeOpacity:0.5, fillOpacity:0.2, fillColor: '#AA0000'}));
circle[circle.length-1].bindTo('center', marker[marker.length-1], 'position');
info.push(new google.maps.InfoWindow({content: '<b>Phone ID:</b> ' + entry.user_uuid + '<br /><b>Callsign:</b> ' + entry.user_callsign + '<br /><b>Time:</b> ' + entry.user_datestamp}));
google.maps.event.addListener(marker[marker.length-1], 'click', function() {info[info.length-1].open(map, marker[marker.length-1]);});
if (entry.user_uuid == device.uuid){
map.setCenter(latLng);
}
});