That's the length of the last polyline.

Try this:

var kilometres = 0;

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")));
  }
  var poly = new GPolyline(pts,colour,width);
  var kilometers += poly.getLength()/1000;
  map.addOverlay(poly);
}

// display total distance
  document.getElementById("distance").innerHTML =
       "The total distance is " + kilometers +"km.";


Watch out for the subtle change on this line to use += rather than =:
  var kilometers += poly.getLength()/1000;


-- 
http://econym.org.uk/gmap
The Blackpool Community Church Javascript Team


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