[OpenLayers-Users] Setting attributes of a Feature.Vector
Christopher Schmidt
crschmidt at metacarta.com
Thu Oct 11 08:09:01 EDT 2007
On Thu, Oct 11, 2007 at 09:17:06AM +0200, Andy Dale wrote:
> "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:
>
> 3) {first: "test", second: 21};
This is the right one.
>
> 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
This should work.
f = new OpenLayers.Feature.Vector(geometry, {'a':'b'});
alert(f.attributes.a);
Should do the trick. Is it not working for you?
Regards,
--
Christopher Schmidt
MetaCarta
More information about the Users
mailing list