Hi there, please have a look at the following code. When the value of i == 0 the alert 1 prints variable values as per logic. But if I try to print values (alert 2), it just says "undefined, undefined". My question is what changes I'll have to make to get the values printed in second alert (Alert 2) same as per alert 1?
var testPoint = [];
function load() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map_canvas"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(52.5271463402545, -1.50573921491311), 8, G_HYBRID_MAP);
GDownloadUrl("controllers/gmap_genxml2.php", function(data) {
var xml = GXml.parse(data);
var markers = xml.documentElement.getElementsByTagName("marker");
for (var i = 0; i < markers.length; i++) {
if(i == 0) {
testPoint["lat"] = parseFloat(markers[i].getAttribute("lat"));
testPoint["lng"] = parseFloat(markers[i].getAttribute("lng"));
/********* ALERT 1 ***********/
alert(testPoint["lat"]+" "+testPoint["lng"]);
/********* ALERT 1 End ***********/
}
var name = markers[i].getAttribute("name");
var address = markers[i].getAttribute("address");
var type = markers[i].getAttribute("type");
var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),
parseFloat(markers[i].getAttribute("lng")));
var marker = createMarker(point, name, address, type);
map.addOverlay(marker);
}
});
/********* ALERT 2 ******************/
alert(testPoint["lat"]+" "+testPoint["lng"]);
/********* ALERT 2 Start ***********/
}
}
Thank you for your help. DeeJay