[OpenLayers-Dev] Bug in OpenLayers.Layer.Vector ?

Christopher Schmidt crschmidt at metacarta.com
Fri May 11 07:33:00 EDT 2007

On Fri, May 11, 2007 at 01:25:48PM +0200, Christine Spietz wrote:
> Hi guys,
> there seems to be a bug (?) in OpenLayers.Layer.Vector.
> Function getFeatureById(fid) seems not to work properly.

ID != fid

> If I select a Feature in the Vector-layer I am able to alert the fid.
> If I try to get the feature with the alerted fid by
> feature = myVectorLayer.getFeatureById(fid);
> alert("feature = "+feature);
> feature is null.

Yes.  The property that getFeatureById is searching for is the 'id'
property, not the 'fid' property.

> Any ideas how to solve this?

there is not currently a getFeatureByFid property -- you will need to
iterate over the layer features, and look for the .fid property.

Christopher Schmidt

More information about the Dev mailing list