I have some problems with my code, I have a list of airports in a sql database, and I want to create markers for each 1 of those airports.
For the address i got ICAO
my guess is because
geocoder.geocode({ 'address': address}, function(results){ ... });
callback is execute in same context.
try execute marker in same context. the code below is will wait for all geocoder fetched. then parse to marker.
var results = {};
var waiting = temp.length;
while(temp.length > 0){
var fetching = temp.pop();
geocoder.geocode(
{ address: fetching},
function(response){
results[fetching] = response[0].geometry.location;
--waiting;
if(waiting == 0) // wait for everything to finish
setMarker();
}
);
}
var setMarker = function(){
for(var element in results){
var marker = new google.maps.Marker({
map: map,
position: results[element],
title: element
});
google.maps.event.addListener(marker, 'click', function() {
window.open ('infomonde.php?icao='+element+'&language=fr', '', 'configs')});
}
}
ps window.open if i'm not mistaken, some browser reject popup title(and might cause unable to open popup). i alway leave blank.