Hi all,

I need some help I'd like to show an InfoWindow for each added marker but I
cannot find how here's my code:

var geocoder;
var map;
var infowindow = new google.maps.InfoWindow();
var radius = 50; // Km
var markerArray = new Array();
var tab = new Array();

function codeAddress() {
var address = document.getElementById("addressInput").value;
     geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var airports = new Array();

// Clear any previous added marker
for (i=0; i<markerArray.length; i++)
{
markerArray[i].setMap(null);
}
markerArray = [];

for (i=0; i<tab.length; i++) {
var latlngStr = tab[i].split(",",2);
var lat = parseFloat(latlngStr[0]);
var lng = parseFloat(latlngStr[1]);
if (haversine(lat, lng, results[0].geometry.location.b,
results[0].geometry.location.c) <= radius)
{
var latlng = new google.maps.LatLng(lat, lng);
airports.push(latlng);
}
}

if (airports.length > 0)
{
map.setCenter(results[0].geometry.location);
for (i=0; i<airports.length; i++)
{
                               var marker = new google.maps.Marker({
               map: map,
                                        position: airports[i]
                                });
                                       markerArray.push(marker);
google.maps.event.addListener(markerArray[markerArray.length -1], 'click',
function() {
        var infowindow = new google.maps.InfoWindow({
content: "salut"
});
infowindow.open(map, markerArray[markerArray.length -1]);
});

}
}
else
{
map.setCenter(new google.maps.LatLng(43, 11));
alert("Sorry no airport found");
}
 } else {
         alert("Geocode was not successful for the following reason: " +
status);
}
});
}

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply via email to