good afternoon! I have a list of markers that is plotted on google maps, I need to show the address when I click on the marker Using the code below it shows the address of the last marker
function updatePontos() {
markers = new Array();
var v = '#{TrPontoTaxiSB.pontosListTaxi}'.replace("[","").replace("]","");
var arr2 = v.split(",");
for (val2 of arr2) {
if (val2 != "") {
var pts = val2.split(";");
var infowindow = new google.maps.InfoWindow();
var marker = new google.maps.Marker({
position: {lat: parseFloat(pts[1]), lng: parseFloat(pts[2])},
draggable: false,
raiseOnDrag: false,
map: map,
title: pts[0],
icon: '#{facesContext.externalContext.requestContextPath}/resources/images/taxi_50.png'
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.setContent(pts[4] + " <br />" + pts[5] + " <br />" + pts[6]);
infowindow.open(map, this);
});
markers.push(marker);
}
}
}
Does anyone know how to show the address according to the selected marker?