Select to view content in your preferred language

Problems to Add Features in AGSFeatureLayerEditingDelegate

4534
4
08-30-2012 04:53 AM
ViniciusMachuca
New Contributor
I need add geometry to Feature Service, but not working. 😞

My flow is:

1. Adopt AGSFeatureLayerEditingDelegate delegate.

2. AGSFeatureLayer *featureLayer = [AGSFeatureLayer featureServiceLayerWithURL: urlFeatureLayer mode: AGSFeatureLayerModeOnDemand];

3. featureLayer.editingDelegate = self;

4.     NSMutableDictionary *graphicAttributes = [[NSMutableDictionary alloc] init];
[graphicAttributes setObject:@"EXAMPLE1" forKey:@"FIELD1"];
[graphicAttributes setObject:@"EXAMPLE2" forKey:@"FIELD2"];
   
5. AGSGraphic *graphic = [AGSGraphic graphicWithGeometry:selectedMaPoint symbol:nil attributes:graphicAttributes infoTemplateDelegate:self];
       
6. [featureLayer addFeatures:[NSArray arrayWithObject:graphic]];


The strange thing is that no delegate is called!

Ex:
- (void)featureLayer:(AGSFeatureLayer *)featureLayer operation:(NSOperation*)op didFeatureEditsWithResults:(AGSFeatureLayerEditResults *)editResults;

- (void)featureLayer:(AGSFeatureLayer *)featureLayer operation:(NSOperation*)op didFailFeatureEditsWithError:(NSError *)error;


Thanks!
0 Kudos
4 Replies
NimeshJarecha
Esri Regular Contributor
Create retain property for feature layer and then try.

//in .h file
@property (nonatomic, retain) AGSFeatureLayer *featureLayer;

//in .m file
self.featureLayer = [AGSFeatureLayer featureServiceLayerWithURL: urlFeatureLayer mode: AGSFeatureLayerModeOnDemand];
self.featureLayer.editingDelegate = self;

Regards,
Nimesh
0 Kudos
VIKRANTKRISHNA
Regular Contributor
I am also trying to do the exact same steps to add feature to a feature layer. The error I am seeing in the log is

AGSJSONRepresentation failed: Error is: NaN is not a valid number in JSON
0 Kudos
NimeshJarecha
Esri Regular Contributor
Do you have a valid geometry in JSON?

Regards,
Nimesh
0 Kudos
HrishikeshPol
Deactivated User

Hi Nimesh,

I have created property for feature layer and I'm trying to add feature from query result. But unable to do that.....delegate methods are not getting called. Below is my code. Will you please help me with this.

- (void)queryTask:(AGSQueryTask *)queryTask operation:(NSOperation*)op didExecuteWithFeatureSetResult:(AGSFeatureSet *)featureSet

{

    NSInteger index;

    for (index = 0; index <featureSet.features.count; index++)

    {

        AGSSimpleFillSymbol * fillSym = [AGSSimpleFillSymbol simpleFillSymbol];

        fillSym.style = AGSSimpleFillSymbolStyleSolid;

        fillSym.color = [UIColor orangeColor];

        AGSGraphic * graphic = [featureSet.features objectAtIndex: index];

        graphic.symbol = fillSym;

        [self.featureLayer1 addFeatures:@[graphic]];

    }

    [self.featureLayer1 refresh];

}

0 Kudos