Re: [OpenLayers-Users] Restore feature's geometry

2009-07-30 Thread Alexandre Dube
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


[OpenLayers-Users] Restore feature's geometry

2009-07-29 Thread Alexandre Dube
Hi,

  I'd like to know if there's a better (faster) way to restore a 
modified feature's geometry other than using layer.refresh({'force':true});

  I use a ModifyFeature control with a popup that as save and cancel 
buttons.  On save, it commits the changes (fine).  On cancel, it should 
'restore' the feature to its original state (at least the geometry).

  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.

  I also tried to clone the geometry only but I had weird behaviors 
(duplicated features).

  Any hint ?

-- 
Alexandre Dubé
Mapgears
www.mapgears.com

___
Users mailing list
Users@openlayers.org
http://openlayers.org/mailman/listinfo/users


Re: [OpenLayers-Users] Restore feature's geometry

2009-07-29 Thread Alexandre Dube
Well, in the end I would really like to avoid the use of 
layer.refresh({'force':true}) if possible.

If you activate the DrawFeature control while modifying a feature 
(instead of hitting cancel), the geometry of the current modified 
feature still needs to be restored (didn't hit the save button).  So 
the following happens :

  1. layer.refresh is called
  2. DrawFeature control activates (at the same time, featureadded 
events are registered)
  3. response from the layer.refresh draws new features, but they get 
all engulfed in the DrawFeature featureadded events (resulting in 
selecting them all in my case)

  So, I would really need an other option...  Any clue ?

  I'll show the weird behavior of cloning the geometry in a live 
example.  Maybe I'm doing something wrong.

Alexandre
 
Alexandre Dube wrote:
 Hi,

   I'd like to know if there's a better (faster) way to restore a 
 modified feature's geometry other than using layer.refresh({'force':true});

   I use a ModifyFeature control with a popup that as save and cancel 
 buttons.  On save, it commits the changes (fine).  On cancel, it should 
 'restore' the feature to its original state (at least the geometry).

   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.

   I also tried to clone the geometry only but I had weird behaviors 
 (duplicated features).

   Any hint ?

   


-- 
Alexandre Dubé
Mapgears
www.mapgears.com

___
Users mailing list
Users@openlayers.org
http://openlayers.org/mailman/listinfo/users


Re: [OpenLayers-Users] Restore feature's geometry

2009-07-29 Thread Alexandre Dube
Hey,

Alexandre Dube wrote:
 Well, in the end I would really like to avoid the use of 
 layer.refresh({'force':true}) if possible.

 If you activate the DrawFeature control while modifying a feature 
 (instead of hitting cancel), the geometry of the current modified 
 feature still needs to be restored (didn't hit the save button).  So 
 the following happens :

   1. layer.refresh is called
   2. DrawFeature control activates (at the same time, featureadded 
 events are registered)
   

I registered the event on the Layer instead of the DrawFeature control.  
That's why I had this behavior.  Registering it to the control instead 
solved that problem.

Still interested to hear more about other (and faster) options though.

Alexandre

   3. response from the layer.refresh draws new features, but they get 
 all engulfed in the DrawFeature featureadded events (resulting in 
 selecting them all in my case)

   So, I would really need an other option...  Any clue ?

   I'll show the weird behavior of cloning the geometry in a live 
 example.  Maybe I'm doing something wrong.

 Alexandre
  
 Alexandre Dube wrote:
   
 Hi,

   I'd like to know if there's a better (faster) way to restore a 
 modified feature's geometry other than using layer.refresh({'force':true});

   I use a ModifyFeature control with a popup that as save and cancel 
 buttons.  On save, it commits the changes (fine).  On cancel, it should 
 'restore' the feature to its original state (at least the geometry).

   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.

   I also tried to clone the geometry only but I had weird behaviors 
 (duplicated features).

   Any hint ?

   
 


   


-- 
Alexandre Dubé
Mapgears
www.mapgears.com

___
Users mailing list
Users@openlayers.org
http://openlayers.org/mailman/listinfo/users