Delete features (feature service)

View inQMLC++
View on GitHub
Sample viewer app

Delete features from an online feature service.

screenshot

Use case

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

How to use the sample

  • click on a feature on the Map
  • click on the delete button

How it works

  1. Create a ServiceFeatureTable object from a URL.
  2. Create a FeatureLayer from the service feature table.
  3. Select features from the feature layer via selectFeatures().
  4. Remove the selected features from the table using deleteFeatures().
  5. Update the table on the server using applyEdits().

Relevant API

  • Feature
  • FeatureLayer
  • ServiceFeatureTable

Tags

deletion, feature, online, Service, table

Sample Code

DeleteFeaturesFeatureService.qmlDeleteFeaturesFeatureService.cppDeleteFeaturesFeatureService.h
                                                           
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// [WriteFile Name=DeleteFeaturesFeatureService, Category=EditData]
// [Legal]
// Copyright 2016 Esri.

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0

// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// [Legal]

import QtQuick 2.6
import QtQuick.Controls 2.2
import Esri.Samples 1.0
import Esri.ArcGISRuntime.Toolkit 100.11

DeleteFeaturesFeatureServiceSample {
    id: deleteFeaturesSample
    width: 800
    height: 600

    MapView {
        id: mapView
        anchors.fill: parent
        objectName: "mapView"

        // map callout window
        Callout {
            id: callout
            calloutData: mapView.calloutData
            borderColor: "lightgrey"
            borderWidth : 1
            accessoryButtonType: "Custom"
            customImageUrl: "qrc:/Samples/EditData/DeleteFeaturesFeatureService/ic_menu_trash_light.png"
            leaderPosition: leaderPositionEnum.Automatic
            onAccessoryButtonClicked: {
                if (callout.visible)
                    callout.dismiss();
                deleteFeaturesSample.deleteSelectedFeature();
            }
        }
    }

    onFeatureSelected: {
        // show the callout
        callout.showCallout();
    }

    onHideWindow: {
        // hide the callout
        if (callout.visible)
            callout.dismiss();
    }
}

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