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

Arnd Wippermann arnd.wippermann at web.de
Mon Aug 2 07:27:04 EDT 2010


register 'loadend' for your layer and declare there your function

    brewpub_layer.events.register("loadend", brewpub_layer, function (e) {
        var fts = this.features;
        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: Montag, 2. August 2010 11:21
Betreff: Re: [OpenLayers-Users] Howto extract
documentattributes(name/description) from KML Layer

Arnd Wippermann <arnd.wippermann at web.de> wrote:

> 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>"; }

Hm fts seems to be of zero length here.

So when do I have to run this code? Looks like the kml is not been read
immediately after layer generation.

Sven

--
"If you don't make lower-resolution mapping data publicly available, there
will be people with their cars and GPS devices, driving around with their
laptops" (Tim Berners-Lee) /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