'AGSFeatureLayer' is loaded using a url from the arcgis server. Now, i would like to add a 'AGSFeature' in 'AGSFeatureLayer'. Is it possible to add a 'AGSFeature' in a 'AGSFeatureLayer' locally or, whether i need to use 'AGSGraphicOverlay' to accomplish that.
Kindly advice. Also give some example.
#2 Is the following way is right one to create AGSGraphic from a AGSFeature?
AGSSymbol * symbol = [self.graphic.featureTable.featureLayer.renderer symbolForFeature:self.feature];
AGSGraphic * graphicObj = [[AGSGraphic alloc] initWithGeometry:self.feature.geometry symbol:symbol attributes:self.feature.attributes];
#3 and i tried the following way to add a feature in feature table, but nothing happens
[layr.featureTable addFeature:data completion:^(NSError * _Nullable error) {
if(error)
{
nlog(@"error: %@",error.localizedFailureReason);
}
}];
Solved! Go to Solution.
Hi,
You don't need to use an AGSGraphic to create a new feature.
The pattern is:
See Edit features—ArcGIS Runtime SDK for iOS | ArcGIS for Developers.
Since you are working with a server (and not local data), then there is one more call to make to push your add to the server, namely applyEdits. The applyEditsWithCompletion() function is found on AGSServiceFeatureTable (and since you created your feature layer with a URL to a service, the AGSFeatureLayer.featureTable property will be an AGSServiceFeatureTable). See the Edit features (connected) sample, in particular the applyEdits call.
This should get you going.
Hi,
You don't need to use an AGSGraphic to create a new feature.
The pattern is:
See Edit features—ArcGIS Runtime SDK for iOS | ArcGIS for Developers.
Since you are working with a server (and not local data), then there is one more call to make to push your add to the server, namely applyEdits. The applyEditsWithCompletion() function is found on AGSServiceFeatureTable (and since you created your feature layer with a URL to a service, the AGSFeatureLayer.featureTable property will be an AGSServiceFeatureTable). See the Edit features (connected) sample, in particular the applyEdits call.
This should get you going.
Hello Nick,
Thanks for the reply. I have used as per the pattern. I have checked 'canUpdateFeature()' method before adding into feature layer, it returns 'NO'. So i removed the condition and created, added a feature in a feature layer. The statements are running successfully, but the added feature is not visible in the feature layer. Im facing the problem in some features, but rest of the feature are working great. No idea what is wrong.
Hello Nick,
If i used apply edits, the feature is added in server and displays in feature layer. But i don't know why it was not displayed before applying applyedits. FYI, But some feature does.
For anyone else following the thread…
After some discussion offline it turns out the layer had a definitionExpression on it which the newly added feature didn't match. So, the new feature was being added to the feature service OK, but was not being displayed in the map.
Glad we were able to figure this out, Muruganandham Kuppan!
Hi Nick,
The method
-(AGSFeature *)createFeatureWithAttributes:(NSDictionary<NSString*,id> *)attributes geometry:(nullable AGSGeometry *)geometry;
returns the OBJECTID as <Null> in attributes of the created feature, but in the previous version it returned as -1, -2, etc., Any suggestions?
Regards,
When you call createFeature() you will get an AGSArcGISFeature back. But until you call applyEdits(), that feature just exist locally and does not have an ID that you should use.
Once you call applyEdits() to write the feature to the service, then there will be an ID to use. Call AGSArcGISFeature.refreshObjectID() on your handle to the feature to populate the OBJECTID.
Cheers,
Nick
Hi,
You should check the canAddFeature property if you're adding rather than canUpdateFeature.
Once you call addFeature:completion: you should see the new feature in the map view. Which version of the Runtime SDK are you using?
Hi,
The runtime SDK version is 100.1. and i checked 'canAddFeature', its returning true.
May be update of SDK will fix the problem?
Could you try that please? Try with the current release (100.2.1).
If you still have problems, let's move to DM and investigate your service and your code to try to build a repro case.