[OpenLayers-Users] Howto extract document attributes(name/description) from KML Layer

Arnd Wippermann arnd.wippermann at web.de
Sun Aug 1 19:01:06 EDT 2010


As you have set extractAttributes to true you can do something like this:

var fts = brewpub_layer.features;

var theHTML = "";

for(var i=0;i<fts.length;i++)
{
      theHTML = fts[i].attributes.name + ", " +
fts[i].attributes.description + "<br>";
}

...

Arnd

-----Ursprüngliche Nachricht-----
Von: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org] Im
Auftrag von Sven Geggus
Gesendet: Sonntag, 1. August 2010 22:32
An: users at openlayers.org
Betreff: [OpenLayers-Users] Howto extract document
attributes(name/description) from KML Layer

Hello,

I'm using a KML layer like this:

var brewpub_layer = new
OpenLayers.Layer.GML("KML", "path/to/my.kml",
              {
              format: OpenLayers.Format.KML,
              projection: map.displayProjection,
              formatOptions: {  
                extractStyles: true,
                extractAttributes: true
               }
             });

This works fine as far as the features are concerned. But I would also like
to extract a few other attributes from the kml file to display them beside
the map.

Currently I'm talking about <name> and <description> attributes only.

How can this be done?

Sven

--
"The term "any key" does not refer to a particular key on the keyboard. It
simply means to strike any one of the keys on your keyboard or handheld
screen." (Compaq FAQ Entry 2859) /me is giggls at ircnet, http://sven.gegg.us/
on the Web _______________________________________________
Users mailing list
Users at openlayers.org
http://openlayers.org/mailman/listinfo/users




More information about the Users mailing list