bluewalrus
10-06-2009, 01:31 AM
I've found the setTimeout function(class, method, ?) but I either don't understand it, don't have it functioning right, or it's not used the way I need it to be. Below is my code. I'm trying to put in a pause between when it goes to the "addToMap" and returns. Right now this outputs all the addresses (30) then loads 30 alert windows. My goal is to have one address then one alert window then the next address and the next alert widnow (in the end i dont want the alerts but I'm using this for debug method right now). There is more javascript but this is the limited code if you need more please let me know and this is inside of a script type text/javascript tag.
<?php
while ($increase2 < $increase ) {
?>
address2 = address;
setTimeout('alert("test");', 1700);
var address = "<?php echo $City[$increase2] . ", ";?> <?php echo $State[$increase2] . ", ";?> <?php echo $Country[$increase2]. ", ";?>";
if (address2 != address) {
geocoder.getLocations(address, addToMap);
}
<?php
$increase2++;
}
?>
}
function addToMap(response)
{
// Retrieve the object
place = response.Placemark[0];
// Retrieve the latitude and longitude
point = new GLatLng(place.Point.coordinates[1],
place.Point.coordinates[0]);
bounds.extend(point);
map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds));
// Create a marker
marker = new GMarker(point);
// Add the marker to map
map.addOverlay(marker);
// Add controls and zoom to map
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
// Add address information to marker
//marker.openInfoWindowHtml(place.address);
}
//]]>
</script>
<?php
while ($increase2 < $increase ) {
?>
address2 = address;
setTimeout('alert("test");', 1700);
var address = "<?php echo $City[$increase2] . ", ";?> <?php echo $State[$increase2] . ", ";?> <?php echo $Country[$increase2]. ", ";?>";
if (address2 != address) {
geocoder.getLocations(address, addToMap);
}
<?php
$increase2++;
}
?>
}
function addToMap(response)
{
// Retrieve the object
place = response.Placemark[0];
// Retrieve the latitude and longitude
point = new GLatLng(place.Point.coordinates[1],
place.Point.coordinates[0]);
bounds.extend(point);
map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds));
// Create a marker
marker = new GMarker(point);
// Add the marker to map
map.addOverlay(marker);
// Add controls and zoom to map
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
// Add address information to marker
//marker.openInfoWindowHtml(place.address);
}
//]]>
</script>