Dear,

I have some trouble to push in a tab some data from an XML file.

First, I use this original script that work fine for extracting data :
http://econym.org.uk/gmap/example_map7.htm

On the code below, pointsparcours.push(pts[i]); normally push in a tab
"lat" and "lng" data. If I use under that "alert(pointsparcours[i]);",
that ok at this point the data is in the tab.

That problem is that when I call the tab "pointsparcours" after
request.send(null);, the tab is empty with an "undefined" message.

My question may be : how to "keep in memory" thess tab data ?

Thanks for all,

Stephane.

**************
    var pointsparcours = [];

      // arrays to hold copies of the markers and html used by the
side_bar
      // because the function closure trick doesnt work there
      var side_bar_html = "";
      var gmarkers = [];
      var htmls = [];
      var i = 0;

      // Read the data from example4.xml
      var request = GXmlHttp.create();
      request.open("GET", "example5.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");

          // ========= Now process the polylines ===========
          var lines =
xmlDoc.documentElement.getElementsByTagName("line");
          // read each line
          for (var a = 0; a < lines.length; a++) {
            // get any line attributes
            var colour = lines[a].getAttribute("colour");
            var width  = parseFloat(lines[a].getAttribute("width"));
            // read each point on that line
            var points = lines[a].getElementsByTagName("point");
            var pts = [];
            for (var i = 0; i < points.length; i++) {
               pts[i] = new
GLatLng(parseFloat(points[i].getAttribute("lat")),
 
parseFloat(points[i].getAttribute("lng")));
                           pointsparcours.push(pts[i]);
                           //alert(pointsparcours[i]);
            }
            map.addOverlay(new GPolyline(pts,colour,width));
          }
          //
================================================
        }
      }
      request.send(null);
**************

-- 
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.

Reply via email to