Alexandre Dube wrote: > Hi Eric, > > Eric Lemoine wrote: > >>> I tried to clone the feature + fid before modifications, then on >>> cancel destroy the original feature and add the clone but it's obviously >>> wrong to do so since it becomes unbound to its source. >>> >>> >> What do you mean by "becomes unbound to its source"? I'd tend to think >> that cloning feature+fid is a good solution... >> >> >> > > Yeah, it's not very clear. What I meant is if I clone the feature, > modify the original then "cancel" --> if I destroy the original and > addFeature(clone), the clone becomes independent of the other features, > i.e. it was not added from a getFeature request, but manually. > > Even when explaining it, it doesn't make much sense. It shouldn't > matter "how" a feature is added to a layer IMO. Maybe I did something > wrong again. I should make a sample and share it. > > I'll let you know when I'm done. > > Thanks > > Alexandre > >
You were right. I don't remember what I did first but obviously I made some mistake because feature.clone() + fid is working just fine. Sorry for the noise. Alexandre == working cloning == olWFSRoads.events.register("beforefeaturemodified", '', onRoadModificationStart); olWFSRoads.events.register("afterfeaturemodified", '', onRoadModificationEnd); function onRoadModificationStart(evt) { var oFeature = evt.feature; // ### HERE ### if(oFeature.state != OpenLayers.State.INSERT){ oFeature.myClone = oFeature.clone(); oFeature.myClone.fid = oFeature.fid; } }; function onRoadModificationEnd(evt) { var oFeature = evt.feature; // ### AND HERE ### switch (oFeature.state) { case OpenLayers.State.INSERT: olWFSRoads.destroyFeatures([oFeature]); break; case OpenLayers.State.UPDATE: //olWFSRoads.refresh({'force':true}); olWFSRoads.addFeatures([oFeature.myClone]); olWFSRoads.destroyFeatures([oFeature]); break; } }; -- Alexandre Dubé Mapgears www.mapgears.com _______________________________________________ Users mailing list Users@openlayers.org http://openlayers.org/mailman/listinfo/users