Skip to content

Commit 93b682e

Browse files
authored
Merge pull request #21 from ArcGIS/sample/Generate-offline-map
New Sample: Generate offline map
2 parents 0190d9e + 296623e commit 93b682e

27 files changed

+709
-0
lines changed

generate-offline-map/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

generate-offline-map/README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Generate offline map
2+
3+
Take a web map offline.
4+
5+
![Image of generate offline map](generate-offline-map.png)
6+
7+
## Use case
8+
9+
Taking a web map offline allows users continued productivity when their network connectivity is poor or nonexistent. For example, by taking a map offline, a field worker inspecting utility lines in remote areas could still access a feature's location and attribute information.
10+
11+
## How to use the sample
12+
13+
Once the map loads, zoom to the extent you want to take offline. The red border shows the extent that will be downloaded. Tap the "Take Map Offline" button to start the offline map job. The progress bar will show the job's progress. When complete, the offline map will replace the online map in the map view.
14+
15+
## How it works
16+
17+
1. Create an `ArcGISMap` with a `Portal` item pointing to the web map.
18+
2. Create `GenerateOfflineMapParameters` specifying the download area geometry, minimum scale, and maximum scale.
19+
3. Create an `OfflineMapTask` with the map.
20+
4. Create the `OfflineMapJob` with `OfflineMapTask.generateOfflineMap(params, downloadDirectoryPath)` and start it with `OfflineMapJob.start()`.
21+
5. When the job is done, get the offline map with `OfflineMapJob.result.offlineMap`.
22+
23+
## Relevant API
24+
25+
* GenerateOfflineMapJob
26+
* GenerateOfflineMapParameters
27+
* GenerateOfflineMapResult
28+
* OfflineMapTask
29+
* Portal
30+
31+
## About the data
32+
33+
The map used in this sample shows the [stormwater network](https://arcgisruntime.maps.arcgis.com/home/item.html?id=acc027394bc84c2fb04d1ed317aac674) within Naperville, IL, USA, with cartography designed for web and mobile devices with offline support.
34+
35+
## Additional information
36+
37+
The creation of the offline map can be fine-tuned using [parameter overrides for feature layers](https://github.com/Esri/arcgis-runtime-samples-android/tree/master/java/generate-offline-map-overrides), or by using [local basemaps](https://github.com/Esri/arcgis-runtime-samples-android/tree/master/java/generate-offline-map-with-local-basemap)
38+
to achieve more customised results.
39+
40+
## Tags
41+
42+
download, offline, save, web map
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"category": "Edit and Manage Data",
3+
"description": "Take a web map offline.",
4+
"formal_name": "GenerateOfflineMap",
5+
"ignore": false,
6+
"images": [
7+
"generate-offline-map.png"
8+
],
9+
"keywords": [
10+
"download",
11+
"offline",
12+
"save",
13+
"web map",
14+
"GenerateOfflineMapJob",
15+
"GenerateOfflineMapParameters",
16+
"GenerateOfflineMapResult",
17+
"OfflineMapTask",
18+
"Portal"
19+
],
20+
"language": "kotlin",
21+
"redirect_from": [
22+
"/android/latest/sample-code/generate-offline-map.htm"
23+
],
24+
"relevant_apis": [
25+
"GenerateOfflineMapJob",
26+
"GenerateOfflineMapParameters",
27+
"GenerateOfflineMapResult",
28+
"OfflineMapTask",
29+
"Portal"
30+
],
31+
"snippets": [
32+
"src/main/java/com/esri/arcgismaps/sample/generateofflinemap/MainActivity.kt"
33+
],
34+
"title": "Generate offline map"
35+
}

generate-offline-map/build.gradle

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
apply plugin: 'com.android.application'
2+
apply plugin: 'org.jetbrains.kotlin.android'
3+
4+
android {
5+
compileSdkVersion rootProject.ext.compileSdkVersion
6+
7+
defaultConfig {
8+
applicationId "com.esri.arcgismaps.sample.generateofflinemap"
9+
minSdkVersion rootProject.ext.minSdkVersion
10+
targetSdkVersion rootProject.ext.targetSdkVersion
11+
versionCode rootProject.ext.versionCode
12+
versionName rootProject.ext.versionName
13+
buildConfigField("String", "API_KEY", API_KEY)
14+
}
15+
16+
buildTypes {
17+
release {
18+
minifyEnabled false
19+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
20+
}
21+
}
22+
23+
buildFeatures {
24+
dataBinding true
25+
viewBinding true
26+
}
27+
}
28+
29+
dependencies {
30+
// lib dependencies from rootProject build.gradle
31+
implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion"
32+
implementation "com.google.android.material:material:$materialVersion"
33+
}
449 KB
Loading
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.esri.arcgismaps.sample.generateofflinemap">
4+
5+
<uses-permission android:name="android.permission.INTERNET" />
6+
7+
<application
8+
android:allowBackup="true"
9+
android:icon="@mipmap/ic_launcher"
10+
android:label="@string/app_name"
11+
android:roundIcon="@mipmap/ic_launcher_round"
12+
android:supportsRtl="true"
13+
android:theme="@style/AppTheme">
14+
<activity
15+
android:exported="true"
16+
android:name=".MainActivity"
17+
android:label="@string/app_name">
18+
<intent-filter>
19+
<action android:name="android.intent.action.MAIN" />
20+
21+
<category android:name="android.intent.category.LAUNCHER" />
22+
</intent-filter>
23+
</activity>
24+
</application>
25+
26+
</manifest>

0 commit comments

Comments
 (0)