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

Christine Spietz spietz at fh-bingen.de
Fri May 11 07:25:48 EDT 2007


Hi guys,

there seems to be a bug (?) in OpenLayers.Layer.Vector.
Function getFeatureById(fid) seems not to work properly.

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.

In my opinion the code in OpenLayers.Layer.Vector.getFeatureById looks fine,
but there must be an error at some point ...

So I made some alerts in the OpenLayers.Layer.Vector.getFeatureById:

-------------------------------->snip out of 
getFeatureById-------------------------
for(var i=0; i<this.features.length; ++i) {
    //new
    alert("this.features[i].id = "+this.features[i].id);
    alert("featureId = "+featureId);
    //end of test
    if(this.features[i].id == featureId) {
        feature = this.features[i];
        break;
    }
}
-------------------------------->snip-------------------------
and the alert is wrong:

first (wrong) alert is:
--> "this.features[i].id = OpenLayers.Feature.Vector_2564"
but it shoulb be for example :
--> "this.features[i].id = 1300_134"

- second alert is all right:
--> "featureId = 1300_134"

Any ideas how to solve this?


Sincerely

Christine




More information about the Dev mailing list