[OpenLayers-Users] Setting attributes of a Feature.Vector

Andy Dale andy.dale at gmail.com
Thu Oct 11 10:52:15 EDT 2007


Hi,

I installed firebug, and managed to track down the cause of my error.

It seems the for loop causes the problem, the following does not work:

function extractDetails() {
            feats = polygonLayer.features;

            for(item in feats) {
                alert(item.attributes.first);
            }
 }

but this does:

function extractDetails() {
            feats = polygonLayer.features;

            for(i = 0; i < feats.length; i++) {
                alert(feats[i].attributes.first);
            }
}

maybe i have got a bit confused over what is possible in wit for loops in
javascript ?

Cheers,

Andy
On 11/10/2007, Christopher Schmidt <crschmidt at metacarta.com> wrote:
>
> On Thu, Oct 11, 2007 at 02:41:05PM +0200, Andy Dale wrote:
> > Hi,
> >
> > Doing it the way you said (directly underneath the feature creation)
> does
> > work, but i want to move the feature attributes extraction to a separate
> > function like so:
>
> This should (in general) work. Do you have firebug? Have you looked at
> the properties of the features on the layer to see what they have? This
> is a very useful to see what's actually there.
>
> If you open the Firebug console and type
> polygonLayer.features[0].attributes, is there anything there? Adding
> things to the Layer.vector does not at all change their attributes
> property at all, so I can't imagine where this is getting lost.
>
> Regards,
> --
> Christopher Schmidt
> MetaCarta
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20071011/a637b172/attachment.html


More information about the Users mailing list