-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3ad9236
commit 61553ca
Showing
85 changed files
with
3,439 additions
and
341 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Edit and sync features with feature service | ||
|
||
Synchronize offline edits with a feature service. | ||
|
||
![Image of edit and sync features with feature service](edit-and-sync-features-with-feature-service.png) | ||
|
||
## Use case | ||
|
||
A survey worker who works in an area without an internet connection could take a geodatabase of survey features offline at their office, make edits and add new features to the offline geodatabase in the field, and sync the updates with the online feature service after returning to the office. | ||
|
||
## How to use the sample | ||
|
||
Pan and zoom into the desired area, making sure the area you want to take offline is within the current extent of the map view. Tap on the "Generate Geodatabase" button to take the area offline. When complete, the map will update with a red outline around the offline area. To edit features, tap to select a feature, and tap again anywhere else on the map to move the selected feature to the tapped location. To sync the edits with the feature service, click the "Sync geodatabase" button. | ||
|
||
## How it works | ||
|
||
1. Create a `GeodatabaseSyncTask` from a URL to a feature service. | ||
2. Use `createDefaultGenerateGeodatabaseParameters()` on the geodatabase sync task to create `GenerateGeodatabaseParameters`, passing in an `Envelope` extent as the parameter. | ||
3. Create a `GenerateGeodatabaseJob` from the `GeodatabaseSyncTask` using `createGenerateGeodatabaseJob(...)` passing in parameters and a path to the local geodatabase. | ||
4. Start the job and get the result `Geodatabase`. | ||
5. Load the geodatabase and get its feature tables. Create feature layers from the feature tables and add them to the map's operational layers collection. | ||
6. Create `SyncGeodatabaseParameters` and set the sync direction. | ||
7. Create a `SyncGeodatabaseJob` from `GeodatabaseSyncTask` using `.createSyncGeodatabaseJob(...)` passing in the parameters and geodatabase as arguments. | ||
8. Start the sync job to synchronize the edits with `syncGeodatabaseJob.start()`. | ||
|
||
## Relevant API | ||
|
||
* FeatureLayer | ||
* FeatureTable | ||
* GenerateGeodatabaseJob | ||
* GenerateGeodatabaseParameters | ||
* GeodatabaseSyncTask | ||
* SyncGeodatabaseJob | ||
* SyncGeodatabaseParameters | ||
* SyncLayerOption | ||
|
||
## Additional information | ||
|
||
This sample uses the GeoViewCompose Toolkit module to be able to implement a Composable MapView. | ||
|
||
## Tags | ||
|
||
feature service, geodatabase, geoviewcompose, offline, synchronize |
42 changes: 42 additions & 0 deletions
42
edit-and-sync-features-with-feature-service/README.metadata.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"category": "Edit and Manage Data", | ||
"description": "Synchronize offline edits with a feature service.", | ||
"formal_name": "EditAndSyncFeaturesWithFeatureService", | ||
"ignore": false, | ||
"images": [ | ||
"edit-and-sync-features-with-feature-service.png" | ||
], | ||
"keywords": [ | ||
"feature service", | ||
"geodatabase", | ||
"geoviewcompose", | ||
"offline", | ||
"synchronize", | ||
"FeatureLayer", | ||
"FeatureTable", | ||
"GenerateGeodatabaseJob", | ||
"GenerateGeodatabaseParameters", | ||
"GeodatabaseSyncTask", | ||
"SyncGeodatabaseJob", | ||
"SyncGeodatabaseParameters", | ||
"SyncLayerOption" | ||
], | ||
"language": "kotlin", | ||
"redirect_from": "", | ||
"relevant_apis": [ | ||
"FeatureLayer", | ||
"FeatureTable", | ||
"GenerateGeodatabaseJob", | ||
"GenerateGeodatabaseParameters", | ||
"GeodatabaseSyncTask", | ||
"SyncGeodatabaseJob", | ||
"SyncGeodatabaseParameters", | ||
"SyncLayerOption" | ||
], | ||
"snippets": [ | ||
"src/main/java/com/esri/arcgismaps/sample/editandsyncfeatureswithfeatureservice/MainActivity.kt", | ||
"src/main/java/com/esri/arcgismaps/sample/editandsyncfeatureswithfeatureservice/components/MapViewModel.kt", | ||
"src/main/java/com/esri/arcgismaps/sample/editandsyncfeatureswithfeatureservice/screens/MainScreen.kt" | ||
], | ||
"title": "Edit and sync features with feature service" | ||
} |
54 changes: 54 additions & 0 deletions
54
edit-and-sync-features-with-feature-service/build.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
plugins { | ||
id("com.android.application") | ||
id("org.jetbrains.kotlin.android") | ||
} | ||
|
||
android { | ||
compileSdk = libs.versions.compileSdk.get().toInt() | ||
|
||
defaultConfig { | ||
applicationId = "com.esri.arcgismaps.sample.editandsyncfeatureswithfeatureservice" | ||
minSdk = libs.versions.minSdk.get().toInt() | ||
targetSdk = libs.versions.targetSdk.get().toInt() | ||
versionCode = libs.versions.versionCode.get().toInt() | ||
versionName = libs.versions.versionName.get() | ||
buildConfigField("String", "API_KEY", project.properties["API_KEY"].toString()) | ||
} | ||
|
||
buildTypes { | ||
release { | ||
isMinifyEnabled = false | ||
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") | ||
} | ||
} | ||
|
||
buildFeatures { | ||
compose = true | ||
buildConfig = true | ||
} | ||
|
||
composeOptions { | ||
kotlinCompilerExtensionVersion = libs.versions.kotlinCompilerExt.get() | ||
} | ||
|
||
namespace = "com.esri.arcgismaps.sample.editandsyncfeatureswithfeatureservice" | ||
} | ||
|
||
dependencies { | ||
// lib dependencies from rootProject build.gradle.kts | ||
implementation(libs.androidx.core.ktx) | ||
implementation(libs.androidx.lifecycle.runtime.ktx) | ||
implementation(libs.androidx.lifecycle.viewmodel.compose) | ||
implementation(libs.androidx.activity.compose) | ||
// Jetpack Compose Bill of Materials | ||
implementation(platform(libs.androidx.compose.bom)) | ||
// Jetpack Compose dependencies | ||
implementation(libs.androidx.compose.ui) | ||
implementation(libs.androidx.compose.material3) | ||
implementation(libs.androidx.compose.ui.tooling) | ||
implementation(libs.androidx.compose.ui.tooling.preview) | ||
implementation(project(":samples-lib")) | ||
// Toolkit dependencies | ||
implementation(platform(libs.arcgis.maps.kotlin.toolkit.bom)) | ||
implementation(libs.arcgis.maps.kotlin.toolkit.geoview.compose) | ||
} |
Binary file added
BIN
+213 KB
...c-features-with-feature-service/edit-and-sync-features-with-feature-service.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions
21
edit-and-sync-features-with-feature-service/proguard-rules.pro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle.kts. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
24 changes: 24 additions & 0 deletions
24
edit-and-sync-features-with-feature-service/src/main/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
<activity | ||
android:exported="true" | ||
android:name=".MainActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
55 changes: 55 additions & 0 deletions
55
...ain/java/com/esri/arcgismaps/sample/editandsyncfeatureswithfeatureservice/MainActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* Copyright 2024 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. | ||
* | ||
*/ | ||
|
||
package com.esri.arcgismaps.sample.editandsyncfeatureswithfeatureservice | ||
|
||
import android.os.Bundle | ||
import androidx.activity.ComponentActivity | ||
import androidx.activity.compose.setContent | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Surface | ||
import androidx.compose.runtime.Composable | ||
import com.arcgismaps.ApiKey | ||
import com.arcgismaps.ArcGISEnvironment | ||
import com.esri.arcgismaps.sample.sampleslib.theme.SampleAppTheme | ||
import com.esri.arcgismaps.sample.editandsyncfeatureswithfeatureservice.screens.MainScreen | ||
|
||
class MainActivity : ComponentActivity() { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
// authentication with an API key or named user is | ||
// required to access basemaps and other location services | ||
ArcGISEnvironment.apiKey = ApiKey.create(BuildConfig.API_KEY) | ||
|
||
setContent { | ||
SampleAppTheme { | ||
SampleApp() | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
private fun SampleApp() { | ||
Surface( | ||
color = MaterialTheme.colorScheme.background | ||
) { | ||
MainScreen( | ||
sampleName = getString(R.string.app_name) | ||
) | ||
} | ||
} | ||
} |
Oops, something went wrong.