Hello! Having this problem parsing XML file and creating markers from data within XML file.
Firebug says that latD is not available. However, inspecting the DOM, latD and lonD are completely populated with the data that I have from the XML file. So why is latD within initialize() not available? Since even the fact that initialize is not called until body is loaded. Code: <head> <script src="http://maps.google.com/maps?file=api&v=2amp;key="aaa" type="text/javascript"></script> <script type="text/javascript" src="http://www.google.com/jsapi"></ script> <script type = "text/javascript"> var fileName = String($fileLoc); var latD; var lonD; function loadXML() { var request = GXmlHttp.create(); request.open("GET", fileName, true); request.onreadystatechange = function() { if(request.readyState == 4) { var xml = GXml.parse(request.responseText); latD = xml.documentElement.getElementsByTagName ("latitude"); lonD = xml.documentElement.getElementsByTagName ("longitude"); } } request.send(null); } loadXML(); function initialize() { var map = new GMap2(document.getElementById("map_canvas")); map.addControl(new GLargeMapControl()); map.addControl(new GMapTypeControl()); map.enableScrollWheelZoom(); map.setCenter(new GLatLng(0, 0), 0); map.setMapType(G_HYBRID_MAP); var bounds = new GLatLngBounds(); for (var i = 0; i < latD.length; i++) { lat = latD[i].childNodes[0].nodeValue; lon = lonD[i].childNodes[0].nodeValue; var point = new GLatLng(lat, lon); var marker = new GMarker(point); map.addOverlay(marker); bounds.extend(point); } // Set center and zoom for map display based on markers map.setZoom(map.getBoundsZoomLevel(bounds) - 1); map.setCenter(bounds.getCenter()); } </script> </head> <body onload = "initialize()" onunload = "GUnload()"> <div id="map_canvas" style="width:1000px; height: 600px"></ div> |; --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Maps API" 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-API?hl=en -~----------~----~----~----~------~----~------~--~---
