On Thu, Aug 25, 2011 at 12:41 PM, Steven M. Ottens <ste...@minst.net> wrote: > 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()?
Hi Steven Currently addFeatures is the only way. But I agree it'd be good to be able to pass features to the constructor. -- Eric Lemoine Camptocamp France SAS Savoie Technolac, BP 352 73377 Le Bourget du Lac, Cedex Tel : 00 33 4 79 44 44 96 Mail : eric.lemo...@camptocamp.com http://www.camptocamp.com _______________________________________________ Dev mailing list d...@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/openlayers-dev