Speak, all right? I'm working on Google maps, grabbing the clients in my bank and putting the Markers on the map according to their latitude and longitude, when clicking the marker opens a window displaying information, so far so good, my problem is:
When I click on a marker, it always opens the last
My code:
JS
$.ajax({
url: url,
format: 'json',
success: function(rows){
rows = $.parseJSON(rows);
for (var i in rows){
var row = rows[i],
id = row[0],
nome = row[1],
lat = row[9],
lon = row[10];
codigo += '';
Here begins the marker - 1st - pick up position
var Posicao = new google.maps.LatLng(lat,lon);
2nd - I do the Marker
var Marker = new google.maps.Marker({
position: Posicao,
map: map,
center: Posicao,
icon: imagemPin,
title:"LUGAR",
zIndex: 3});
3rd - window info
var textoInfo = "<img src='img/logo.png' style='width: 60%;'><p>Ola"+nome+", voce ta por aqui!</p>";
var infoLocal = new google.maps.InfoWindow({
content: textoInfo
});
4th - here the event when I click on a Marker
google.maps.event.addListener(Marker, "click", function() {
infoLocal.open(map,Marker);
});
//END MARKER
}
}
});