Add features to a feature layer.
Use case
An end-user performing a survey may want to add features to the map during the course of their work.
How to use the sample
Click on a location on the map to add a feature at that location.
How it works
A Feature instance is added to a ServiceFeatureTable which then pushes that new feature to the server.
- Create a
ServiceGeodatabasefrom a URL. - Get a
ServiceFeatureTablefrom theServiceGeodatabase. - Create a
FeatureLayerderived from theServiceFeatureTableinstance. - Create a
Featurewith attributes and a location using theServiceFeatureTable. - Add the
Featureto theServiceFeatureTable. - Apply edits to the
ServiceGeodatabasewhich will upload the new feature to the online service.
Relevant API
- Feature
- FeatureEditResult
- FeatureLayer
- ServiceFeatureTable
- ServiceGeodatabase
Additional information
When editing feature tables that are subject to database behavior (operations on one table affecting another table), it's now recommended to call these methods (apply edits & undo edits) on the ServiceGeodatabase object rather than on the ServiceFeatureTable object. Using the ServiceGeodatabase object to call these methods will prevent possible data inconsistencies and ensure transactional integrity so that all changes can be commited or rolled back.
Tags
edit, feature, online service
Sample Code
<UserControl x:Class="ArcGISRuntime.WinUI.Samples.AddFeatures.AddFeatures"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:esriUI="using:Esri.ArcGISRuntime.UI.Controls">
<Grid>
<esriUI:MapView x:Name="MyMapView" />
<Border Style="{StaticResource BorderStyle}">
<TextBlock FontWeight="SemiBold"
Text="Tap to add features."
TextAlignment="Center" />
</Border>
</Grid>
</UserControl>