Select to view content in your preferred language

Edit invisible featurelayer

844
1
02-26-2014 01:15 PM
AndrzejMilosz
Deactivated User
Hello,
I work around this sample: https://developers.arcgis.com/flex/sample-code/editor.htm
What I want to do is to make existing features invisible, but the editor should stay enabled to add new features. Added features should stay visible during running browser sesion.
I tried to do like in the code below, but this disables editor for this layer.
<esri:FeatureLayer id="incidentsAreas" visible="false"
 mode="snapshot"
 url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/HomelandSecurity/operations/FeatureServer/2"/>


Is there other solution?

Thank you,
Andrzej
Tags (2)
0 Kudos
1 Reply
RobertScheitlin__GISP
MVP Emeritus
Andrzej,

   The layer has to be visible to be edited. So you would have to apply a definitionExpression to the FeatureLayer and the expression would have to something like 'NOT ObjectId IN (1,2,3,etc)' an feed the expression the list of current objectids. You would be the list of current ObjectIds by doing an QueryTask.executeForIds

Some thing like this:

 private var query:Query = new Query;
        private var queryTask:QueryTask = new QueryTask();
        query.returnGeometry = false;
        query.outFields = ["objectid"]
        query.objectIds = null;
        query.where = "1=1";
        queryTask.url = "http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/HomelandSecurity/operations/FeatureServer/2";
        queryTask.executeForIds(query, new AsyncResponder(onExecuteForIdsComplete, queryTask_faultHandler));

        private function onExecuteForIdsComplete(objectIds:Array, token:Object = null):void
        {
     //Apply a definition expression that removes all the current objectids
     //Now you should only have the new features you create visible
     incidentsAreas.definitionExpression = "NOT objectid IN (" + objectIds.join(',') + ")";
        }

        private function queryTask_faultHandler(info:Object, token:Object = null):void
        {
            //do nothing
        }
0 Kudos