Switching from AGSFeatureLayer to AGSFeatureTable

4772
3
01-06-2015 10:35 AM
KyleDunaway
New Contributor III

Hello all,

So I've been using AGSFeatureLayer along with AGSGraphic to add/edit/delete features from layers.

for(AGSGraphic *graphic in self.featureLayer)...

This has worked great, letting me cycle through the feature layer and find graphics I need/want to change.

Now that I have been working on getting the app to run offline, I found that I need to create a geodatabase with feature tables.

I created a geodatabase, a tpk file, etc.

When offline, I can load the layers from the geodatabase, they come in as AGSFeatureTables in geodatabase.featureTables.

Then I use AGSFeatureTableLayer to add them to the map.

My problem comes from AGSFeatureLayer has a graphics layer, while AGSFeatureTableLayer doesnt. 

When I need to get a feature, am I suppose to use the queryWithResults function on AGSFeatureTable everytime?

Thanks for any advice/help.

Tags (1)
0 Kudos
3 Replies
KyleDunaway
New Contributor III

So Im using queryResultsWithParameters to get the features from the layer.

This works, and I can access the features.

Thanks

0 Kudos
HrishikeshPol
New Contributor

Hey,

I'm trying to add features to feature layer. But unable add it. Below is my code. Can you help me to do this please?

in viewDidLoad

self.featureLayer1.queryDelegate = self;

    self.queryTask = [[AGSQueryTask alloc] initWithURL:self.featureLayer1.URL];

    self.queryTask.delegate = self;

   

    self.query = [AGSQuery query];

    User *user = [ModelFacade currentUserInContext:[ModelFacade currentContext]];

    self.query.whereClause = [NSString stringWithFormat:@"UserID='{%@}'", user.userID];

    self.query.geometry = envelope;

    [self.queryTask executeWithQuery:self.query] ;

#delegate method.

- (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 blackColor];

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

        graphic.symbol = fillSym;

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

    }

    [self.featureLayer1 refresh];

    NSLog(featureSet.features);

Able to get all records in log but not on map view.

Can you please help me with this.

}

0 Kudos
DiveshGoyal
Esri Regular Contributor

Can you make sure that the result features geometry is in the same spatial reference as the map's spatial reference? You'll need to set AGSQuery outSpatialReference property

0 Kudos