Skip to content

Commit 2d0c7de

Browse files
authored
New sample: Manage features (#331)
2 parents 84deac9 + 023d5c6 commit 2d0c7de

File tree

11 files changed

+679
-0
lines changed

11 files changed

+679
-0
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ build/
1515
*.classpath
1616
.settings/
1717
.vscode
18+
*.salive
1819

1920
# OS generated files #
2021
.DS_Store

Diff for: .kotlin/sessions/kotlin-compiler-17391608372419177291.salive

Whitespace-only changes.

Diff for: samples/manage-features/README.md

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Manage features
2+
3+
Create, update, and delete features to manage a feature layer.
4+
5+
![Screenshot of manage features](manage-features.png)
6+
7+
## Use case
8+
9+
An end-user performing a survey may want to manage features on the map in various ways during the course of their work.
10+
11+
## How to use the sample
12+
13+
Pick an operation, then tap on the map to perform the operation at that location. Available feature management operations include: "Create feature", "Delete feature", "Update attribute", and "Update geometry".
14+
15+
## How it works
16+
17+
1. Create a `ServiceGeodatabase` from a URL.
18+
2. Get a `ServiceFeatureTable` from the `ServiceGeodatabase`.
19+
3. Create a `FeatureLayer` derived from the `ServiceFeatureTable` instance.
20+
4. Apply the feature management operation upon tapping the map.
21+
- Create features: create a `Feature` with attributes and a location using the `ServiceFeatureTable`.
22+
- Delete features: delete the selected `Feature` from the `FeatureTable`.
23+
- Update attribute: update the attribute of the selected `Feature`.
24+
- Update geometry: update the geometry of the selected `Feature`.
25+
5. Update the `FeatureTable` locally.
26+
6. Update the `ServiceGeodatabase` of the `ServiceFeatureTable` by calling `applyEdits()`. This pushes the changes to the server.
27+
28+
## Relevant API
29+
30+
* Feature
31+
* FeatureEditResult
32+
* FeatureLayer
33+
* ServiceFeatureTable
34+
* ServiceGeodatabase
35+
36+
## Additional information
37+
38+
When editing feature tables that are subject to database behavior (operations on one table affecting another table), it's recommended to call these methods (apply or undo edits) on the `ServiceGeodatabase` object rather than on the `ServiceFeatureTable` object. Using the `ServiceGeodatabase` object to call these operations will prevent possible data inconsistencies and ensure transactional integrity so that all changes can be committed or rolled back.
39+
40+
## Tags
41+
42+
amend, attribute, create, delete, deletion, details, edit, editing, feature, feature layer, feature table, geodatabase, information, moving, online service, service, update, updating, value

Diff for: samples/manage-features/README.metadata.json

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"category": "Edit and Manage Data",
3+
"description": "Create, update, and delete features to manage a feature layer.",
4+
"formal_name": "ManageFeatures",
5+
"ignore": false,
6+
"images": [
7+
"manage-features.png"
8+
],
9+
"keywords": [
10+
"amend",
11+
"attribute",
12+
"create",
13+
"delete",
14+
"deletion",
15+
"details",
16+
"edit",
17+
"editing",
18+
"feature",
19+
"feature layer",
20+
"feature table",
21+
"geodatabase",
22+
"information",
23+
"moving",
24+
"online service",
25+
"service",
26+
"update",
27+
"updating",
28+
"value",
29+
"Feature",
30+
"FeatureEditResult",
31+
"FeatureLayer",
32+
"ServiceFeatureTable",
33+
"ServiceGeodatabase"
34+
],
35+
"language": "kotlin",
36+
"redirect_from": "",
37+
"relevant_apis": [
38+
"Feature",
39+
"FeatureEditResult",
40+
"FeatureLayer",
41+
"ServiceFeatureTable",
42+
"ServiceGeodatabase"
43+
],
44+
"snippets": [
45+
"src/main/java/com/esri/arcgismaps/sample/managefeatures/components/ManageFeaturesViewModel.kt",
46+
"src/main/java/com/esri/arcgismaps/sample/managefeatures/MainActivity.kt",
47+
"src/main/java/com/esri/arcgismaps/sample/managefeatures/screens/ManageFeaturesScreen.kt"
48+
],
49+
"title": "Manage features"
50+
}

Diff for: samples/manage-features/build.gradle.kts

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
plugins {
2+
alias(libs.plugins.arcgismaps.android.library)
3+
alias(libs.plugins.arcgismaps.android.library.compose)
4+
alias(libs.plugins.arcgismaps.kotlin.sample)
5+
alias(libs.plugins.gradle.secrets)
6+
}
7+
8+
secrets {
9+
// this file doesn't contain secrets, it just provides defaults which can be committed into git.
10+
defaultPropertiesFileName = "secrets.defaults.properties"
11+
}
12+
13+
android {
14+
namespace = "com.esri.arcgismaps.sample.managefeatures"
15+
buildFeatures {
16+
buildConfig = true
17+
}
18+
}
19+
20+
dependencies {
21+
// Only module specific dependencies needed here
22+
}

Diff for: samples/manage-features/manage-features.png

163 KB
Loading

Diff for: samples/manage-features/src/main/AndroidManifest.xml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3+
4+
<uses-permission android:name="android.permission.INTERNET" />
5+
6+
<application><activity
7+
android:exported="true"
8+
android:name=".MainActivity"
9+
android:label="@string/manage_features_app_name">
10+
11+
</activity>
12+
</application>
13+
14+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/* Copyright 2025 Esri
2+
*
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*
15+
*/
16+
17+
package com.esri.arcgismaps.sample.managefeatures
18+
19+
import android.os.Bundle
20+
import androidx.activity.ComponentActivity
21+
import androidx.activity.compose.setContent
22+
import androidx.compose.material3.MaterialTheme
23+
import androidx.compose.material3.Surface
24+
import androidx.compose.runtime.Composable
25+
import com.arcgismaps.ApiKey
26+
import com.arcgismaps.ArcGISEnvironment
27+
import com.esri.arcgismaps.sample.sampleslib.theme.SampleAppTheme
28+
import com.esri.arcgismaps.sample.managefeatures.screens.ManageFeaturesScreen
29+
30+
class MainActivity : ComponentActivity() {
31+
32+
override fun onCreate(savedInstanceState: Bundle?) {
33+
super.onCreate(savedInstanceState)
34+
// authentication with an API key or named user is
35+
// required to access basemaps and other location services
36+
ArcGISEnvironment.apiKey = ApiKey.create(BuildConfig.ACCESS_TOKEN)
37+
38+
setContent {
39+
SampleAppTheme {
40+
ManageFeaturesApp()
41+
}
42+
}
43+
}
44+
45+
@Composable
46+
private fun ManageFeaturesApp() {
47+
Surface(color = MaterialTheme.colorScheme.background) {
48+
ManageFeaturesScreen(
49+
sampleName = getString(R.string.manage_features_app_name)
50+
)
51+
}
52+
}
53+
}

0 commit comments

Comments
 (0)