Select to view content in your preferred language

Edit FeatureLayer outside Map

1836
2
Jump to solution
07-21-2014 04:40 PM
KyleDunaway
Deactivated User

Is it possible to edit a feature layer outside of a mapView?

If so, how?

featureLayer = [[AGSFeatureLayer alloc] initWithURL:url mode?]

Thanks

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
DiveshGoyal
Esri Regular Contributor

Yes, it is possible, although some things might be easier if the layer was added to the map view.

If you don't add it to the map, you will probably need to instantiate the feature layer in either snapshot mode, or selection mode. This doc, ArcGIS Feature layer , contains some information about the different modes.(In contrast, the OnDemand mode is better suited for when you add the layer to the map, in which case the layer will retrieve features from the service that fall within the map's view extent.)

Without adding the layer to the map, the features won't display, and users won't be able to tap on a feature to begin editing. Your app will need to handle this workflow a different way or write some code to provide this experience.

To edit a specific feature, you will first need to query it using [AGSFeatureLayer queryFeatures:]. Once you have a reference to the feature, you can modify its attributes/attachments/geometry, and then send the updates back to the service using [AGSFeatureLayer applyEditsWithFeaturesToAdd:toUpdate:toDelete: ]

This sample (RelatedRecordEditingSample) uses this pattern to edit records (incident notes) that are related to a feature layer (incidents). The incident notes are pure tabular data and cannot be visualized on a map, hence the feature layer that is used to edit them is not added to a map. (See NotesViewController.m )

View solution in original post

0 Kudos
2 Replies
DiveshGoyal
Esri Regular Contributor

Yes, it is possible, although some things might be easier if the layer was added to the map view.

If you don't add it to the map, you will probably need to instantiate the feature layer in either snapshot mode, or selection mode. This doc, ArcGIS Feature layer , contains some information about the different modes.(In contrast, the OnDemand mode is better suited for when you add the layer to the map, in which case the layer will retrieve features from the service that fall within the map's view extent.)

Without adding the layer to the map, the features won't display, and users won't be able to tap on a feature to begin editing. Your app will need to handle this workflow a different way or write some code to provide this experience.

To edit a specific feature, you will first need to query it using [AGSFeatureLayer queryFeatures:]. Once you have a reference to the feature, you can modify its attributes/attachments/geometry, and then send the updates back to the service using [AGSFeatureLayer applyEditsWithFeaturesToAdd:toUpdate:toDelete: ]

This sample (RelatedRecordEditingSample) uses this pattern to edit records (incident notes) that are related to a feature layer (incidents). The incident notes are pure tabular data and cannot be visualized on a map, hence the feature layer that is used to edit them is not added to a map. (See NotesViewController.m )

0 Kudos
KyleDunaway
Deactivated User

Thank you Mr. Goyal,

I created the feature layer with initwithURL, queried it, then saved the features.

Looped the features in the layer for the one i wanted, edited its attributes, and updated.

Worked perfect.

Thank you for the comment and reply.  It was much appreciated and helpful.

0 Kudos