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

Christopher Schmidt crschmidt at metacarta.com
Mon May 4 12:40:45 EDT 2009


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



More information about the Dev mailing list