I have a FeatureStore instance associated with a map vector layer, the vector 
layer has a DrawFeature control associated with it.

When a new feature is created the FeatureStore.onFeaturesAdded() method is 
called to create a new record in the store for the feature.  The record is 
created but it does not receive the Open Layers feature ID because it's in an 
INSERT state, as per this code in the FeatureReader class:

                // newly inserted features need to be made into phantom records
                var id = (feature.state === OpenLayers.State.INSERT) ? 
undefined : feature.id;
                records[records.length] = new recordType(values, id);

If I save the vector layer the feature is updated to no longer be in an INSERT 
state.  When I try to retrieve the record for the feature from the store using 
the FeatureStore.getRecordFromFeature() method it fails due to this logic in 
FeatureStore.getRecordFromFeature():

            if(feature.state !== OpenLayers.State.INSERT) {
                record = this.getById(feature.id);
            } else {
                var index = this.findBy(function(r) {
                    return r.get("feature") === feature;
                });
                if(index > -1) {
                    record = this.getAt(index);
                }
            }

The record is no longer in an INSERT state so it will try to find the record by 
feature ID but the record only exists as a phantom (ID less) record in the 
store.

Is this a bug or do I need to explicitly update the record in the store after 
the feature is saved?

Cheers
Adam
_______________________________________________
Users mailing list
[email protected]
http://www.geoext.org/cgi-bin/mailman/listinfo/users

Reply via email to