|
Array of objects question !
I have a question regarding Javascript object arrays -
Suppose I have a global variable which is an object array
//Global variable Point Of Interest
var PointsOfInterest = new Array('lat','lng');
I also have a table named markers in my MySQL database, the script phpsqlajax_genxml.php reads the database, outputs it into XML.
//-------------Read the markers/Points of interest from the database----------------
GDownloadUrl("phpsqlajax_genxml.php", function(data) {
var xml = GXml.parse(data);
var markers = xml.documentElement.getElementsByTagName("marker");
for (var i = 0; i < markers.length; i++) {
PointsOfInterest[i] = (parseFloat(markers[i].getAttribute("lat")), parseFloat(markers[i].getAttribute("lng")) );
}
});
I want to be able to assign the object of "markers" to PointsOfInterest,
e.g. if
markers[o].lat = 56.4113 and markers[0].lng = -2.9145
then I should be able to assign,
PointsOfInterest[0] = markers[0];
and then later be able to call PointsOfInterest[0].lat and PointsOfInterest[0].lng so that they return values 56.4113 and -2.9145 respectively
Any idea on how to do this ?
Thanks,
Amol
|