I have a website that loops through six XML data files and displays corresponding markers on the map and related data in six different sidebars:
http://www.craterpdc.org/transportation/webmap/mpomap.htm My problem is, upon initial viewing, only the last group of markers is put on the map and nothing goes in the sidebars. When I refresh the page, everything works fine. If I go to other websites and come back to the map, everything is fine. If I close the browser and open it again, the initial viewing is incomplete as described above. Here is (I think) the relative code: // Read the data from each XML file var xmldata = ""; var xmlfile = []; xmlfile[0] = "2031_LRTP_Chesterfield.xml"; xmlfile[1] = "2031_LRTP_Colonial_Heights.xml"; xmlfile[2] = "2031_LRTP_Dinwiddie.xml"; xmlfile[3] = "2031_LRTP_Hopewell.xml"; xmlfile[4] = "2031_LRTP_Petersburg.xml"; xmlfile[5] = "2031_LRTP_Prince_George.xml"; for (var x = 0; x < 6; x++) { xmldata = xmlfile[x]; var request = GXmlHttp.create(); request.open("GET", xmldata, true); //request.open("GET", "2031_LRPT_Colonial_Heights.xml", true); request.onreadystatechange = function() { if (request.readyState == 4) { var xmlDoc = GXml.parse(request.responseText); // obtain the array of markers and loop through it var markers = xmlDoc.documentElement.getElementsByTagName("marker"); for (var i = 0; i < markers.length; i++) { // obtain the attribues of each marker var lat = parseFloat(markers[i].getAttribute("lat")); var lng = parseFloat(markers[i].getAttribute("lng")); var point = new GLatLng(lat,lng); var project = markers[i].getAttribute("project"); var fullname = markers[i].getAttribute("fullname"); var locality = markers[i].getAttribute("locality"); var description = markers[i].getAttribute("description"); var from = markers[i].getAttribute("from"); var to = markers[i].getAttribute("to"); var type = markers[i].getAttribute("type"); // create the marker var marker = createTabbedMarker(point,project,fullname,locality,description,from,to,type,"MPO 1","MPO 2"); map.addOverlay(marker); } // put the assembled side_bar_html contents into the side_bar divs if (x==0){ document.getElementById("side_bar_Chesterfield").innerHTML = side_bar_html; side_bar_html = ""; } else if (x==1) { document.getElementById("side_bar_Colonial_Heights").innerHTML = side_bar_html; side_bar_html = ""; } else if (x==2) { document.getElementById("side_bar_Dinwiddie").innerHTML = side_bar_html; side_bar_html = ""; } else if (x==3) { document.getElementById("side_bar_Hopewell").innerHTML = side_bar_html; side_bar_html = ""; } else if (x==4) { document.getElementById("side_bar_Petersburg").innerHTML = side_bar_html; side_bar_html = ""; } else if (x==5) { document.getElementById("side_bar_Prince_George").innerHTML = side_bar_html; side_bar_html = ""; } } } request.send(null); // A function to create the marker and set up the event window function createTabbedMarker(point,project,fullname,locality,description,from,to,type,label1,label2) { var marker = new GMarker(point); GEvent.addListener(marker, "click", function() { marker.openInfoWindowTabsHtml([new GInfoWindowTab(label1,fullname + xmldata + project), new GInfoWindowTab(label2,locality)]); }); // save the info we need to use later for the side_bar gmarkers[i] = marker; markerGroups[locality].push(marker); // add a line to the side_bar html side_bar_html += '<a href="javascript:myclick(' + i + ')" style="color: rgb(0,38,115); text-decoration: none">' + "(" + project + ") " + fullname + " " + '</a> '+ type +' <br>'; i++; return marker; }} Thank you very much for your help. -- 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.
