Skip to content

Commit ac7ba46

Browse files
authored
Merge pull request #25 from ArcGIS/sample/Download-vector-tiles-to-local-cache
Download vector tiles to local cache
2 parents 2424ba2 + ce2f450 commit ac7ba46

File tree

28 files changed

+833
-0
lines changed

28 files changed

+833
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Download vector tiles to local cache
2+
3+
Export tiles from an online vector tile service.
4+
5+
![Image of download vector tiles to local cache](download-vector-tiles-to-local-cache.png)
6+
7+
## Use case
8+
9+
Field workers with limited network connectivity can use exported vector tiles as a basemap for use while offline.
10+
11+
## How to use the sample
12+
13+
When the vector tiled layer loads, zoom in to the extent you want to export. The red box shows the extent that will be exported. Click the "Export Vector Tiles" button to start the job. An error will show if the extent is larger than the maximum limit allowed. When finished, a dialog will show the exported result in a new map view.
14+
15+
## How it works
16+
17+
1. Create an `ArcGISVectorTiledLayer` from the map's base layers.
18+
2. Create an `ExportVectorTilesTask` using the vector tiled layer's URL.
19+
3. Create default `ExportVectorTilesParameters` from the task, specifying extent and maximum scale.
20+
4. Create a `ExportVectorTilesJob` from the task using the parameters, and specifying a vector tile cache path and an item resource path. The resource path is required if you want to export the tiles with the style.
21+
5. Start the job, and once it completes successfully, get the resulting `ExportVectorTilesResult`.
22+
6. Get the `VectorTileCache` from the result to create an `ArcGISVectorTiledLayer` that can be displayed to the map view.
23+
24+
## Relevant API
25+
26+
* ArcGISVectorTiledLayer
27+
* ExportVectorTilesJob
28+
* ExportVectorTilesParameters
29+
* ExportVectorTilesResult
30+
* ExportVectorTilesTask
31+
* VectorTileCache
32+
33+
## Additional information
34+
35+
**NOTE:** Downloading Tiles for offline use requires authentication with the web map's server. To use this sample, you will require an [ArcGIS Online](https://www.arcgis.com) account.
36+
37+
Vector tiles have high drawing performance and smaller file size compared to regular tiled layers, due to consisting solely of points, lines, and polygons. However, in ArcGIS Maps SDK they cannot be displayed in scenes. Visit the [ArcGiS Online Developer's portal](https://developers.arcgis.com/android/layers/layer-types/) to Learn more about the characteristics of ArcGIS vector tiled layers.
38+
39+
## Tags
40+
41+
cache, download, offline, vector
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"category": "Edit and Manage Data",
3+
"description": "Export tiles from an online vector tile service.",
4+
"formal_name": "DownloadVectorTilesToLocalCache",
5+
"ignore": false,
6+
"images": [
7+
"download-vector-tiles-to-local-cache.png"
8+
],
9+
"keywords": [
10+
"cache",
11+
"download",
12+
"offline",
13+
"vector",
14+
"ArcGISVectorTiledLayer",
15+
"ExportVectorTilesJob",
16+
"ExportVectorTilesParameters",
17+
"ExportVectorTilesResult",
18+
"ExportVectorTilesTask",
19+
"VectorTileCache"
20+
],
21+
"language": "kotlin",
22+
"redirect_from": [
23+
"/android/latest/sample-code/download-vector-tiles-to-local-cache.htm"
24+
],
25+
"relevant_apis": [
26+
"ArcGISVectorTiledLayer",
27+
"ExportVectorTilesJob",
28+
"ExportVectorTilesParameters",
29+
"ExportVectorTilesResult",
30+
"ExportVectorTilesTask",
31+
"VectorTileCache"
32+
],
33+
"snippets": [
34+
"src/main/java/com/esri/com/arcgismaps/sample/downloadvectortilestolocalcache/MainActivity.kt"
35+
],
36+
"title": "Download vector tiles to local cache"
37+
}
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.downloadvectortilestolocalcache"
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+
}
98.8 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.com.arcgismaps.sample.downloadvectortilestolocalcache">
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)