[OpenLayers-Users] OpenLayers.Format.GPX read function, syntax to read 'ele' tags

digby digbymaass at gmail.com
Fri Mar 29 07:28:31 PDT 2013


I'm thrashing around in the dark here, trying to read the 'ele' tags in a GPX
file. This cobbled together code from bits and pieces doesn't get anywhere
near working but I can't find actual examples anywhere, or help with the
API.
The map itself is quite successful for showing (and toggling) gpx tracks,
and displaying the lengths. See  wed-slow-fast27mar.htm
<http://www.carnethy.com/maps/wed_training/2013/iframecontent/wed-slow-fast27mar.htm>  
but I'd now like to add the total ascents as well.

var runslow = "../gpx/wed-slow-06feb13.gpx"

read: function (runslow){
	//(and what is this if clause for??)
        if (typeof runslow == "string") {
	runslow = OpenLayers.Format.XML.prototype.read.apply(this, [runslow]);
	}
	var ascent = null;				  
	var eles = runslow.getElementsByTagName("ele");
	for (var i=0, len=eles.length; i<len; i++) {
		if (eles[i] > eles[i-1])                 
		ascent = ascent + (eles[i] - eles[i-1]);
	}};



--
View this message in context: http://osgeo-org.1560.n6.nabble.com/OpenLayers-Format-GPX-read-function-syntax-to-read-ele-tags-tp5043697.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.


More information about the Users mailing list