[OpenLayers-Dev] initialise layer.vector with features doesn't work

Steven M. Ottens steven at minst.net
Thu Aug 25 06:41:30 EDT 2011


Hi all,

I'm trying to initialise a vector layer directly with features eg:
var params = { features: new OpenLayers.Geometry.Point(5,52) };
layer = new OpenLayers.Layer.Vector('name', params);

However, the Vector class initialises with an empty features array and 
overrides my passed in features array, see line 267: 
http://trac.osgeo.org/openlayers/browser/trunk/openlayers/lib/OpenLayers/Layer/Vector.js#L267

The API docs suggest it is possible to pass in features, although 
doesn't explicitly say so ( 
http://dev.openlayers.org/apidocs/files/OpenLayers/Layer/Vector-js.html#OpenLayers.Layer.Vector.features 
)

Is this a bug or a feature?

If it is a feature what is the preferred way to initialise a vector 
layer with a feature? Or should I first initialise the vector layer and 
then use addFeature()?

Regards,
Steven








More information about the Dev mailing list