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

Andy Dale andy.dale at gmail.com
Thu Oct 11 03:17:06 EDT 2007


Hi,

I am currently using Vector layer and creating features (currently only have
a single feature) on it.  The feature i am drawing is a regular polygon, it
is created like so:

var cirFeature = new OpenLayers.Feature.Vector (
                                new
OpenLayers.Geometry.Polygon.createRegularPolygon(new
OpenLayers.Geometry.Point(0, 0), 21.0, 40, 0));

After reading the documentation, i discovered that the attributes can be set
in the constructor as the second parameter.  The documentation states that
the second parmeter is:

"An optional object that will be mapped to the
attributes<http://dev.openlayers.org/docs/files/OpenLayers/Feature/Vector-js.html#OpenLayers.Feature.Vector.attributes>property."

So I attempted to set the second parameter in a varity of ways such as:

1) new Array("value1","value2","value3");
2) {attrtibutes: {first: "test", second: 21}};
3) {first: "test", second: 21};

I attempt to access the attributes as follows:

1) Call Layer.Vector.features
2) Iterate over the returned features
3) On each feature call Feature.attributes
4) Try and access the attributes

In the above steps 1-4, 4 always fails becuase there are never any
attributes set,  can anyone point out where i have gone wrong ?


Thanks in advance,

Andy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20071011/b8abda2f/attachment.html


More information about the Users mailing list