title: OpenLayers: parse GPX file, read 'ele' tags and calculate height gained
body: <p>"The OpenLayers method is not especially well documented" someone said, which is why I can't fathom how to read the 'ele' data in a gpx file, sum it, and display the height gained.</p>
  
  <p>I have a map with 2 gpx layers showing run traces, with a div showing the length of runs and controls to switch layers on and off. Here is one layer:</p>
  
  <pre><code>var lgpx = new OpenLayers.Layer.Vector("wed training fast", {
  strategies: [new OpenLayers.Strategy.Fixed()],
  protocol: new OpenLayers.Protocol.HTTP({
     url: "../gpx/27-Mar-13fast.gpx",
     format: new OpenLayers.Format.GPX({
     extractWaypoints: true, extractRoutes: true,
      extractAttributes: true})
  }),
  styleMap: gpxStyles,
  projection: new OpenLayers.Projection("EPSG:4326")
  });
  
  map.addLayer(lgpx); //fast
  bounds = new OpenLayers.Bounds();
  
  // fit fast layer to bounds of window and add start, finish pins
  lgpx.events.register("loadend", lgpx, function() {
  //add extent of layer to bounds
      bounds = this.getDataExtent();
  //add startpoint marker
      var startPoint = this.features[0].geometry.components[0];               
      layerMarkers.addMarker(new OpenLayers.Marker
          (new OpenLayers.LonLat(startPoint.x, startPoint.y),iconfast));
  //add endpoint marker           
      var endPoint=this.features[0].geometry.components
          [this.features[0].geometry.components.length-1];
      layerMarkers.addMarker(new OpenLayers.Marker
          (new OpenLayers.LonLat(endPoint.x, endPoint.y),iconfast2));
  //calculate length of trace
      var len = this.features[0].geometry.getGeodesicLength
          (new OpenLayers.Projection("EPSG:900913"))/1000 + " k";
      (Math.round(value*100)/100).toFixed(2);
      var kms = +(parseFloat(len).toFixed(2));
      var m = +(parseFloat(kms*0.621371).toFixed(2));
  //write the result to the page      
      document.getElementById("fastbox").innerHTML=
     "Fast run &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;strong&gt;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;&amp;mdash;
         &lt;/strong&gt;&amp;nbsp;&amp;nbsp;" + m +" miles"  +"&amp;nbsp;&amp;nbsp;(" +kms + "k)";
  });
  </code></pre>