Select to view content in your preferred language

clone features

848
1
Jump to solution
09-12-2012 06:32 AM
PaulHastings1
Deactivated User
this has been driving me crazy for days now. i probably have a conceptual problem....

i have a map service w/feature layers that act as kind of a template. the idea is users will clone a set of features from various feature layers, change a few attributes & add them back to the original feature layers--these will be later edited.

the featureLayers are held in an object (ippLayers with the layer name as the key). a set of queryTasks are executed for the features for each layer the user wants & the results are accumulated in an array (cloneLayers). works ok. when the app determines that the queries are finished it tries to add the queried features back.

what i'm seeing is either that nothing is added to the feature layers or a feature or two are added over & over again for the number of layers in the map service (which seems to indicate that the features aren't advancing in the loop but the debugger's not showing that).

any ideas?  thanks.

protected function addClonedLayers(): void {  var l:int;      var i:int;  var clonedFeatures:Array;  var thisGraphic:Graphic;  for (l=0; l < cloneLayers.length; l++) {        if (cloneLayers.clonedLayer.features.length > 0) {    clonedFeatures=[];    for (i=0; i < cloneLayers.clonedLayer.features.length; i++) {     thisGraphic=new Graphic();     thisGraphic=cloneLayers.clonedLayer.features;            thisGraphic.attributes.themeID=themeID;     thisGraphic.attributes.caseID=caseID;                                 // NULL out existing objectID ??     thisGraphic.attributes.OBJECTID=null;     clonedFeatures.push(thisGraphic);           }    ippLayers[cloneLayers.id].applyEdits(clonedFeatures,null,null,true);    }       }  utils.informUser("Cloning complete.","Clone case"); } 
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
PaulHastings1
Deactivated User
and the answer is to use FeatureLayerTask instead.


protected function queryCompleteHandler(featureSet:FeatureSet,token:Object):void {        cloneLayers.push({"token":ObjectUtil.clone(token),"fs":featureSet});
// done yet?
if (cloneLayers.length == ippMapService.layerInfos.length) {
  cloneIPPCaseWindow.currentState="cloningState";
  var feature:Graphic;
  var featureTask:FeatureLayerTask;
  var features:Array;
  var atk:Object;
  for (var l:int=0; l<cloneLayers.length;l++) {
   features=[];
   for (var i:int=0; i< cloneLayers.fs.features.length; i++) {
                                // make cloned features part of this case
    cloneLayers.fs.features.attributes.OBJECTID=null; // probably not needed
    cloneLayers.fs.features.attributes.themeID=themeID;
    cloneLayers.fs.features.attributes.caseID=caseID;
    feature=new Graphic(cloneLayers.fs.features.geometry,null,cloneLayers.fs.features.attributes);
    features.push(feature);
   }
  atk={};
  atk.name=cloneLayers.token.name;
  atk.featuresCount=cloneLayers.fs.features.length;
  featureTask=new FeatureLayerTask(cloneLayers.token.url);
  featureTask.showBusyCursor=true;
  featureTask.applyEdits(features,null,null,null,true,new AsyncResponder(onCloneUpdate,onFault,atk));
}
ippMapService.refresh();
        }   
}

View solution in original post

0 Kudos
1 Reply
PaulHastings1
Deactivated User
and the answer is to use FeatureLayerTask instead.


protected function queryCompleteHandler(featureSet:FeatureSet,token:Object):void {        cloneLayers.push({"token":ObjectUtil.clone(token),"fs":featureSet});
// done yet?
if (cloneLayers.length == ippMapService.layerInfos.length) {
  cloneIPPCaseWindow.currentState="cloningState";
  var feature:Graphic;
  var featureTask:FeatureLayerTask;
  var features:Array;
  var atk:Object;
  for (var l:int=0; l<cloneLayers.length;l++) {
   features=[];
   for (var i:int=0; i< cloneLayers.fs.features.length; i++) {
                                // make cloned features part of this case
    cloneLayers.fs.features.attributes.OBJECTID=null; // probably not needed
    cloneLayers.fs.features.attributes.themeID=themeID;
    cloneLayers.fs.features.attributes.caseID=caseID;
    feature=new Graphic(cloneLayers.fs.features.geometry,null,cloneLayers.fs.features.attributes);
    features.push(feature);
   }
  atk={};
  atk.name=cloneLayers.token.name;
  atk.featuresCount=cloneLayers.fs.features.length;
  featureTask=new FeatureLayerTask(cloneLayers.token.url);
  featureTask.showBusyCursor=true;
  featureTask.applyEdits(features,null,null,null,true,new AsyncResponder(onCloneUpdate,onFault,atk));
}
ippMapService.refresh();
        }   
}
0 Kudos