Delete features (feature service)

View inAndroidFormsUWPWPFWinUIiOSView on GitHubSample viewer app

Delete features from an online feature service.

Image of delete features feature service

Use case

Sometimes users may want to delete features from an online feature service.

How to use the sample

To delete a feature, tap it, then click 'Delete incident'.

How it works

  1. Create a ServiceGeodatabase object from a URL.
  2. Get a ServiceFeatureTable object from the ServiceGeodatabase object.
  3. Create a FeatureLayer object from the service feature table.
  4. Select features from the feature layer via FeatureLayer.SelectFeatures().
  5. Remove the selected features from the service feature table using ServiceFeatureTable.DeleteFeatureAsync().
  6. Update the table on the server using ServiceFeatureTable.ServiceGeodatabase.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

deletion, feature, online, Service, table

Sample Code

DeleteFeatures.xamlDeleteFeatures.xamlDeleteFeatures.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
<UserControl x:Class="ArcGISRuntime.WPF.Samples.DeleteFeatures.DeleteFeatures"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013">
    <Grid>
        <esri:MapView x:Name="MyMapView" />
        <Border Style="{StaticResource BorderStyle}">
            <Label HorizontalContentAlignment="Center"
                   Content="Tap to select features for deletion."
                   FontWeight="SemiBold" />
        </Border>
    </Grid>
</UserControl>

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.

You can no longer sign into this site. Go to your ArcGIS portal or the ArcGIS Location Platform dashboard to perform management tasks.

Your ArcGIS portal

Create, manage, and access API keys and OAuth 2.0 developer credentials, hosted layers, and data services.

Your ArcGIS Location Platform dashboard

Manage billing, monitor service usage, and access additional resources.

Learn more about these changes in the What's new in Esri Developers June 2024 blog post.

Close