Update a feature's location in an online feature service.
Use case
Sometimes users may want to edit features in an online feature service by moving them.
How to use the sample
Tap a feature to select it. Tap again to set the updated location for that feature. An alert will be shown confirming success or failure.
How it works
- Create a
ServiceGeodatabaseobject from a URL. - Get the
ServiceFeatureTablefrom theServiceGeodatbaseobject. - Create a
FeatureLayerobject from theServiceFeatureTable. - Select a feature from the feature layer, using
FeatureLayer.SelectFeatures. - Load the selected feature.
- Change the selected feature's location using
Feature.Geometry = geometry. - After the change, update the table on the server using
ApplyEditsAsync.
Relevant API
- Feature
- 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
editing, feature layer, feature table, moving, service, updating
Sample Code
<UserControl x:Class="ArcGISRuntime.WinUI.Samples.UpdateGeometries.UpdateGeometries"
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 a feature to select. Tap again to update its location."
TextAlignment="Center" />
</Border>
</Grid>
</UserControl>