[OpenLayers-Dev] Layer.GML how to access the XML?

gwales gary_wales at hotmail.com
Mon May 4 14:46:34 EDT 2009

Christopher Schmidt-2 wrote:
> On Mon, May 04, 2009 at 09:07:50AM -0700, gwales wrote:
>> Having followed an example, I have a GPX tracklog file loading nicely on
>> my
>> map. I would like to parse the XML and place a marker at each point on
>> the
>> route on a timer to effectively play back the route (like Google Earth
>> can
>> do).
>> I need to access the XML to walk the route but am stumped. The original
>> XML
>> passed to OpenLayers.Layer.GML doesn't seem to be available to me and has
>> been converted to an SVG object.
> Why do you need the original XML? The Layer .features[0] has the
> linestring, and you can iterate over .geometry.components to get them
> out...
>> I can also see a linestring in the geometry property of features but I
>> just
>> cannot work out how to access it.
> It's unclear to me what you're having problems accessing. The Geometry
> is a 
> http://dev.openlayers.org/apidocs/files/OpenLayers/Geometry/LineString-js.html
> which is a subclass of 
> http://dev.openlayers.org/apidocs/files/OpenLayers/Geometry/Collection-js.html#OpenLayers.Geometry.Collection
> and has points as .components, which you can .clone() to make your own
> features, or access .x, .y of.
> -- 
> Christopher Schmidt
> MetaCarta
> _______________________________________________
> Dev mailing list
> Dev at openlayers.org
> http://openlayers.org/mailman/listinfo/dev

I could see from firebug that features[0].geometry was possibly the answer
to my issue but on trying to access features[0] i get 'undefined' and if try
to go deeper than that I get an error.

Code is:
             // Add the Layer with GPX Track
             var lgpx = new OpenLayers.Layer.GML("MMGPX",
"TrackLogs/MM_TL_1.gpx", {
                 format: OpenLayers.Format.GPX,
                 style: {strokeColor: "blue", strokeWidth: 5, strokeOpacity:
                 projection: new OpenLayers.Projection("EPSG:4326")
        	var featGeom=lgpx.features[0].geometry;

I am unsure what I am doing incorrectly in trying to access that linestring?

View this message in context: http://n2.nabble.com/Layer.GML-how-to-access-the-XML--tp2788029p2788792.html
Sent from the OpenLayers Dev mailing list archive at Nabble.com.

More information about the Dev mailing list