Work with offline data

Consider taking individual layers offline as offline data if you want to construct the map or scene yourself and provide users with up-to-date information from ArcGIS Online or ArcGIS Enterprise. This topic describes how to generate and download offline data to use the following layers offline:

You can export and download tiled layer caches locally and access them while your device is offline. It is important to note that you cannot edit tiled layer data (vector tiled data and image tiled data). If you require updates to the tiled layer data, you must export and download them again.

Feature and annotation layers

You can take features (including annotation, related records, and attachments) offline, from a feature service, by downloading them to geodatabase feature tables within a mobile geodatabase. To do this, the feature service must be hosted on ArcGIS Enterprise 10.2.2 or later for features or from a service hosted in ArcGIS Online, provided that the feature service has been sync enabled (allow disconnected editing with synchronization).

You can use an existing feature service or create feature services for your own data. To enable synchronization for a feature service, do the following:

  • ArcGIS Online — Edit the feature service item and check the Sync check box.
  • ArcGIS Enterprise — See Prepare data for offline use in the ArcGIS Server documentation.

To create the mobile geodatabase, you must do the following:

  1. Generate geodatabase parameters and define the area of interest, the layers, any expression filters, and so on, if required.
  2. Create the geodatabase, populate it with all the relevant features, and download it to the user's device.

Generate geodatabase parameters

When you create a mobile geodatabase, you must provide a set of parameters, described below, to define exactly which data is downloaded.

  • The geographical area of interest. You typically supply the area of interest as an extent (in other words, an envelope) but point, line, and polygon (including multipart) geometries are also supported. This allows you to create more detailed areas of interest. Regardless of the geometry, any features that intersect with the supplied area of interest are extracted.
  • The spatial reference of the mobile geodatabase.
  • Individual layers can be managed using the GenerateGeodatabaseParameters.layerOptions property:
    • Determine which layers are included in the mobile geodatabase.
    • Subset the features by providing an expression that filters features by attribute values, such as ZONE = 'COM'.
    • The synchronization model controls how edits made to the mobile geodatabase are applied back to the feature service during synchronization. The model supported is defined by the data that was used to create the sync-enabled feature service. If the data is nonversioned, the synchronization model is per layer. This is the most flexible model, allowing you to synchronize on a layer-by-layer basis, based on the layers you specify. If the data is versioned, the synchronization model is per geodatabase. This synchronizes the entire geodatabase, including all layers and tables, at once.
    • Specify whether to include feature attachments in the mobile geodatabase and whether they can be uploaded during synchronization.
    • Identify whether tables related to the layer are also included in the geodatabase.

You can obtain a default set of parameters (GenerateGeodatabaseParameters) using the createDefaultGenerateGeodatabaseParameters() method on the GeodatabaseSyncTask. If you provide the area of interest, the default parameters will be generated taking into account the capabilities supported by the ArcGIS feature service. You can update these default parameter values before creating the geodatabase.

Use dark colors for code blocksCopy
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
        // Instantiate the geodatabase sync task and create the generate geodatabase parameters.
        val featureServiceUrl =
            "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Sync/SaveTheBaySync/FeatureServer"
        val geodatabaseSyncTask = GeodatabaseSyncTask(featureServiceUrl)

        // In a common workflow, your app prompted the user to zoom/pan to the area they want to take offline.
        // Get the map view's current visible area.
        val polygon = mapView.visibleArea ?: return logErr("The map view has no visible area.")
        val extent: Envelope = polygon.extent

        lifecycleScope.launch {
            geodatabaseSyncTask.load().onFailure { error ->
                // If the geodatabase sync task fails to load, show the error and return.
                return@launch logErr("Failed to load the geodatabase sync task: ${error.message}")
            }
            // Create generate geodatabase parameters for the selected extent.
            val generateGeodatabaseParameters =
                geodatabaseSyncTask.createDefaultGenerateGeodatabaseParameters(extent)
                    .getOrElse { error ->
                        return@launch logErr("Error creating geodatabase parameters: ${error.message}")
                    }

            // Set the synchronization model per layer.
            generateGeodatabaseParameters.syncModel = SyncModel.Layer

            // Define the layers and features to use.
            val marineLayerId = 0
            val birdsLayerId = 1
            val dolphinsOnlyWhereClause = "type = 11"

            // Clear any existing layer options, and then populate the marine layer options.
            generateGeodatabaseParameters.layerOptions.clear()
            generateGeodatabaseParameters.layerOptions.add(
                GenerateLayerOption(
                    layerId = marineLayerId.toLong(),
                    whereClause = dolphinsOnlyWhereClause
                )
            )
            // Populate the bird layer options.
            generateGeodatabaseParameters.layerOptions.add(
                GenerateLayerOption(
                    layerId = birdsLayerId.toLong()
                )
            )

            // Do not return attachments.
            generateGeodatabaseParameters.returnAttachments = false

            // Continues in next example...

Create the geodatabase

Obtain a job to generate and download the geodatabase by passing the GenerateGeodatabaseParameters to the GeodatabaseSyncTask.createGenerateGeodatabaseJob() method on the GeodatabaseSyncTask class. Run the job to generate and download the geodatabase to the device.

Use dark colors for code blocksCopy
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
            // ... continues from previous example.

            // Create the generate geodatabase job, pass in the parameters and an output path for the local geodatabase.
            val generateGdbJob = geodatabaseSyncTask.createGenerateGeodatabaseJob(
                parameters = generateGeodatabaseParameters,
                pathToGeodatabaseFile = appDataStoragePath + File.separator + "localGeodatabase.geodatabase"
            )

            // Collect the job status when it changes: NotStarted, Started, Succeeded, Failed, etc.
            lifecycleScope.launch {
                generateGdbJob.status.collect { jobStatus ->
                    logInfo("Job status changed to: ${jobStatus.javaClass.simpleName}")
                }
            }
            val jobStarted = generateGdbJob.start()
            // Continues in the next example...

If you generate the geodatabase using these methods, it will automatically register the geodatabase with its original service. This allows the data in the geodatabase to be synchronized with the original service. If you want to load this geodatabase onto a number of devices and allow those users to synchronize changes with the original service, you must register these individual geodatabases with the original service.

Create layers from geodatabase feature tables

Use dark colors for code blocksCopy
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
            // ... continues from the previous example.

            // Get the geodatabase from the generate geodatabase job, and
            // create layers from the feature tables that the geodatabase contains.
            val geodatabase = generateGdbJob.result().getOrElse { error ->

                val message = StringBuilder().apply {
                    appendLine("Error fetching geodatabase: ${error.message}.")
                    appendLine("The generate geodatabase job's final status is: ${generateGdbJob.status.value.javaClass.simpleName}.")
                    appendLine("The submitted job # was: ${generateGdbJob.serverJobId}.")
                }
                return@launch logErr(message.toString())
            }
            logInfo("The server job ID is: ${generateGdbJob.serverJobId}.")
            // Load the geodatabase.
            geodatabase.load().onFailure { error ->
                return@launch logErr("Error loading geodatabase: ${error.message}")
            }
            // Create a new feature layer for each feature table in the local geodatabase.
            geodatabase.featureTables.forEach { geodatabaseFeatureTable ->
                val featureLayer = FeatureLayer.createWithFeatureTable(geodatabaseFeatureTable)
                mapView.map?.operationalLayers?.add(featureLayer)
            }
            geodatabase.annotationTables.forEach { annotationFeatureTable ->
                val annotationLayer = AnnotationLayer(annotationFeatureTable)
                mapView.map?.operationalLayers?.add(annotationLayer)
            }
            // unregister since we are not syncing
            geodatabaseSyncTask.unregisterGeodatabase(geodatabase)

Now that you have a geodatabase on your local machine or device, you'll create the relevant layer from the geodatabase feature tables.

  1. Get the geodatabase from the generate geodatabase job.
  2. Load the geodatabase.
    1. Create feature layers from the geodatabase feature tables.
    2. Create annotation layers from the geodatabase annotation tables.

Tiled layers

Tiled layers typically provide geographical context to your map or scene as basemaps that display beneath your data layers. Tiled layers may also provide offline elevation data for visualizing 3D terrain in a scene. You can export and download tile caches directly to your device from any tiled data source that is export enabled. Esri provides a number of vector and raster basemaps for you to export and download:

Download vector tiled data

You can take vector tiled data offline by exporting it from an ArcGIS vector tile service and downloading it as a vector tile package (.vtpk) using the ExportVectorTilesTask class. The vector tile service used for this operation must support the creation of an offline vector tile cache; specifically, it must enable the  exportTiles operation. Vector tiles contain vector representations of data that can be restyled for different purposes, such as day and night viewing. You can download default styling resources along with the vector tiles and custom style resources from ArcGIS Portal items that host vector tile layers.

You have a number of workflows available to you depending on whether your vector tiled data has custom style resources, whether you want to download many custom styles that you can apply to a number of tile caches, or whether you just want to obtain the default tile cache.

To create a vector tile package (.vtpk file) and vector tile style resources, do the following:

  1. Instantiate the export vector tiles task and check whether the vector tiles have custom style resources.
  2. Specify the export vector tiles task parameters for a specific maximum scale and area of interest.
  3. Export the vector tiles. The vector tile package is populated with vector tiles and the default style resources from the ArcGIS vector tile service.

Instantiate the export vector tiles task

Instantiate the ExportVectorTilesTask using a URL to the portal item that represents an ArcGIS vector tiled layer. Load the task, and upon completion, check whether the vector tiles have custom style resources by checking the hasStyleResources Boolean value.

Use dark colors for code blocksCopy
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
            // Connect to a portal (ArcGIS Online) to access a portal item ("Colored pencil" vector tile layer).
            val vectorTiledLayerItem = PortalItem(
                portal = Portal("https://www.arcgis.com"),
                itemId = "4cf7e1fb9f254dcda9c8fbadb15cf0f8"
            )
            val vectorTiledLayer = ArcGISVectorTiledLayer(vectorTiledLayerItem)

            val vectorTiledLayerUri = vectorTiledLayer.uri
                ?: return@launch logErr("Could not retrieve uri of the vector tiled layer.")

            // Create a new export vector tiles task, using the URI of the vector tiled layer.
            // Alternatively, you can pass the PortalItem instance itself.
            val exportVectorTilesTask = ExportVectorTilesTask(vectorTiledLayerUri)

            exportVectorTilesTask.load().getOrElse { error ->
                return@launch logErr("Could not load the export vector tiles task: ${error.message}")
            }
            logInfo("The export vector tiles task loaded.")

            // Check if the vector tile layer has style resources.
            val hasStyleResources = exportVectorTilesTask.hasStyleResources
            // Choose whether to download just the style resources or both the styles and the tiles.
            if (hasStyleResources) {
                // Download both the style resources and the tiles.
                //...
                logInfo("The export vector tiles task has style resources.")
            } else {
                // Download only the tiles.
                //...
                logInfo("The export vector tiles task does not have style resources.")
            }

Specify the export vector tiles task parameters

To obtain a default set of parameters, call the createDefaultExportVectorTilesParameters method and provide an area of interest (polygon or envelope) and a maximum scale. When you provide the maximum scale, you must be aware that there won't be any tiles when the map is zoomed in beyond this scale. If you set the maximum scale to 0, the export will include all levels of detail in the service.

This method returns the set of default parameters, ExportVectorTilesParameters, required to export the vector tiles to a vector tile package. The LODs have been calculated to support the maximum scale that you specified.

Use dark colors for code blocksCopy
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
            // Set the parameters of the export vector tiles task using the geometry of the area to export and its max scale.
            val exportVectorTilesParameters =
                exportVectorTilesTask.createDefaultExportVectorTilesParameters(
                    areaOfInterest = geometry,
                    // Set the max scale parameter to 10% of the map's scale so the
                    // number of tiles exported is within the vector tiled layer's max tile export limit.
                    maxScale = mapView.mapScale.value * 0.1
                ).getOrElse { error ->
                    return@launch logErr(error.message.toString())
                }

            // Create a job with the export vector tile parameters and the path to the vtpk.
            val exportVectorTilesJob = exportVectorTilesTask.createExportVectorTilesJob(
                parameters = exportVectorTilesParameters,
                downloadFilePath = appDataStoragePath + File.separator + "VectorTiles/myVectorTiles.vtpk"
            )

Export the vector tiles

Obtain a job to generate and download a vector tile package and its default style resources by passing the ExportVectorTilesParameters to the createExportVectorTilesJob() method on the ExportVectorTilesTask class. You must also provide a download path to store the vector tile package and its default style resources.

Run the ExportVectorTilesJob to export and download the vector tile package (.vtpk).

Use dark colors for code blocksCopy
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
            val vectorTiledLayerUri = vectorTiledLayer.uri
                ?: return@launch logErr("Could not retrieve uri of the vector tiled layer.")

            // Create a new export vector tiles task, using the URI of the vector tiled layer.
            // Alternatively, you can pass the PortalItem instance itself.
            val exportVectorTilesTask = ExportVectorTilesTask(vectorTiledLayerUri)

            exportVectorTilesTask.load().getOrElse { error ->
                return@launch logErr("Could not load the export vector tiles task: ${error.message}")
            }
            logInfo("The export vector tiles task loaded.")

            // Set the parameters of the export vector tiles task using the geometry of the area to export and its max scale.
            val exportVectorTilesParameters =
                exportVectorTilesTask.createDefaultExportVectorTilesParameters(
                    areaOfInterest = geometry,
                    // Set the max scale parameter to 10% of the map's scale so the
                    // number of tiles exported is within the vector tiled layer's max tile export limit.
                    maxScale = mapView.mapScale.value * 0.1
                ).getOrElse { error ->
                    return@launch logErr(error.message.toString())
                }

            // Create a job with the export vector tile parameters and the path to the vtpk.
            val exportVectorTilesJob = exportVectorTilesTask.createExportVectorTilesJob(
                parameters = exportVectorTilesParameters,
                downloadFilePath = appDataStoragePath + File.separator + "VectorTiles/myVectorTiles.vtpk"
            )

            lifecycleScope.launch {
                exportVectorTilesJob.status.collect { jobStatus ->
                    logInfo("Job status changed to: ${jobStatus.javaClass.simpleName}")
                }
            }

            // Display map if job succeeds.
            lifecycleScope.launch {
                val vectorTilesResult: ExportVectorTilesResult =
                    exportVectorTilesJob.result().getOrElse { error ->

                        return@launch logErr("The export vector tile job failed to return a package: ${error.message}.")
                    }

                val vectorTileCache = vectorTilesResult.vectorTileCache
                    ?: return@launch logErr("Cannot find the tile cache.")
                logInfo("The vector tile cache is downloaded at: ${vectorTileCache.path}")

                // Create a vector tiled layer from the vector tile cache.
                val localVectorTiledLayer = ArcGISVectorTiledLayer(
                    vectorTileCache = vectorTileCache,
                )

                mapView.map = ArcGISMap(Basemap(localVectorTiledLayer))

            }
            // start the export vector tile cache job
            exportVectorTilesJob.start()

Export the vector tiles with custom style resources

Obtain a job to generate and download a vector tile package containing tiles and associated style resources by passing the ExportVectorTilesParameters to the createExportVectorTilesJob() method on the ExportVectorTilesTask class. The portal item's associated style resources will be downloaded and saved separately. You must also provide a download path to store the vector tile package and a separate download path for the style resources.

Run the job to export and download the vector tile package (.vtpk) and the style resources to the device.

Use dark colors for code blocksCopy
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
            // Get the portal item for the layer.
            val vectorTiledLayerItemId = vectorTiledLayer.item?.itemId
                ?: return@launch logErr("Could not retrieve item ID from the vector tiled layer.")
            val vectorTiledLayerItem = PortalItem(portal, vectorTiledLayerItemId)

            // Create a new export vector tiles task.
            val exportVectorTilesTask = ExportVectorTilesTask(vectorTiledLayerItem)
            exportVectorTilesTask.load().getOrElse { error ->
                return@launch logErr("The export vector tiles task failed to load: ${error.message}")
            }
            logInfo("The export vector tiles task loaded.")

            // Set the parameters of the export vector tiles task using the geometry of the area to
            // export and its max scale.
            val exportVectorTilesParameters =
                exportVectorTilesTask.createDefaultExportVectorTilesParameters(
                    areaOfInterest = geometry,
                    // Set the max scale parameter to 10% of the map's scale so the
                    // number of tiles exported are within the vector tiled layer's max tile export limit.
                    maxScale = mapView.mapScale.value * 0.1
                ).getOrElse { error ->
                    return@launch logErr(error.message.toString())
                }

            // Create a job with the export vector tile parameters, the path to the .vtpk, and the path
            // to the style item resources.
            val exportVectorTilesJob = exportVectorTilesTask.createExportVectorTilesJob(
                parameters = exportVectorTilesParameters,
                vectorTileCachePath = appDataStoragePath + File.separator + "VectorTilesAndStyleItemResources/myVectorTiles.vtpk",
                itemResourceCachePath = appDataStoragePath + File.separator + "VectorTilesAndStyleItemResources"
            )

            lifecycleScope.launch {
                exportVectorTilesJob.status.collect { jobStatus ->
                    logInfo("Job status changed to: ${jobStatus.javaClass.simpleName}")
                }
            }

            // Display map if job succeeds.
            lifecycleScope.launch {
                val vectorTilesResult: ExportVectorTilesResult =
                    exportVectorTilesJob.result().getOrElse { error ->

                        return@launch logErr("The export vector tiles job failed to return a package and item resource: ${error.message.toString()}.")
                    }
                val vectorTileCacheFile = vectorTilesResult.vectorTileCache
                    ?: return@launch logErr("Cannot find tile cache.")
                val itemResourceCacheDir = vectorTilesResult.itemResourceCache
                    ?: return@launch logErr("Cannot find item resource cache.")
                logInfo("The vector tile cache (.vtpk) and item resources are downloaded at: ${itemResourceCacheDir.path}")

                // Create a vector tiled layer from the vector tile cache file and item resource cache directory.
                vectorTiledLayer = ArcGISVectorTiledLayer(
                    vectorTileCache = vectorTileCacheFile,
                    itemResourceCache = vectorTilesResult.itemResourceCache
                )

                mapView.map = ArcGISMap(Basemap(vectorTiledLayer))


            }
            // start the export vector tile cache job
            exportVectorTilesJob.start()

Export custom style resources

Obtain a job to download any custom style resources associated with the tasks vector tiles by passing a download path to the createExportStyleResourceCacheJob() method on the ExportVectorTilesTask class.

Run the job to export the style resources. Obtain the itemResourceCache property from the ExportVectorTilesResult class.

Use dark colors for code blocksCopy
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
            val vectorTiledLayerItemId = vectorTiledLayer.item?.itemId
                ?: return@launch logErr("Could not retrieve item Id from the vector tiled layer.")

            // Create a new export vector tiles task.
            val exportVectorTilesTask = ExportVectorTilesTask(vectorTiledLayerItem)
            exportVectorTilesTask.load().getOrElse { error ->
                return@launch logErr("The export vector tiles task failed to load: ${error.message}")
            }

            // Create a job with the export vector tile parameters and the path to the style item resources directory.
            val exportStyleJob: ExportVectorTilesJob =
                exportVectorTilesTask.createExportStyleResourceCacheJob(
                    itemResourceCachePath = appDataStoragePath + File.separator + "StyleItemResources"
                )

            lifecycleScope.launch {
                exportStyleJob.status.collect { jobStatus ->
                    logInfo("Job status changed to: ${jobStatus.javaClass.simpleName}")
                }
            }

            // Display map if job succeeds.
            lifecycleScope.launch {
                val jobResult: ExportVectorTilesResult =
                    exportStyleJob.result().getOrElse { error ->

                        return@launch logErr("The export style job did not return an item resource: ${error.message.toString()}.")
                    }
                val itemResourceCache = jobResult.itemResourceCache
                    ?: return@launch logErr("Cannot find item resource cache.")

            }
            exportStyleJob.start()

Download image tiled data

You can take image tiled data offline by exporting and downloading the image tiled data as a tile package (.tpk or .tpkx) using the ExportTileCacheTask class. This task requires that the tiled map or image service support the creation of an offline tile cache; specifically, it must enable the exportTiles operation. This can be found at the bottom of the service's HTML page. Esri provided basemaps and elevation sources will be swapped for their export-enabled services. To create the tile cache, do the following:

  1. Generate the default export image tile cache parameters and set any of the properties.
  2. Export and download the image tile cache using the methods on the ExportTileCacheTask.

Generate default export image tile cache parameters

Construct a default set of parameters (ExportTileCacheParameters) by passing an area of interest (polygon or envelope) along with the minimum and maximum scale thresholds to the createDefaultExportTileCacheParameters method on the ExportTileCacheTask class.

This method will return a set of parameters for the area of interest and will calculate the levels of detail (LODs) required to support the minimum and maximum scale for the service's tiling scheme. You can adjust these LOD levels or remove some before you download the cache.

Use dark colors for code blocksCopy
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
            val tilesMapServiceURL = "https://tiledbasemaps.arcgis.com/arcgis/rest/services/World_Imagery/MapServer"

            // Instantiate an export tiles task with the URL to the tiled service.
            val exportTileCacheTask = ExportTileCacheTask(tilesMapServiceURL)
            exportTileCacheTask.load().onFailure { error ->
                return@launch logErr("Failed to load export tile cache task: ${error.message}")
            }
            if (exportTileCacheTask.mapServiceInfo == null) {
                logErr("Failed to retrieve the map service info from the MapServer.")
            }

            val envelope = Envelope(
                xMin = -117.205,
                yMin = 34.035,
                xMax = -117.148,
                yMax = 34.064,
                spatialReference = SpatialReference.wgs84()
            )

            val exportTileCacheParameters = exportTileCacheTask.createDefaultExportTileCacheParameters(
                areaOfInterest = envelope,
                minScale = 150000.0,
                maxScale = 5000.0
            ).getOrElse { error ->
                return@launch logErr("Unable to create the default export tile cache parameters: ${error.message}")
            }
            logInfo("The default export tile cache parameters were created.")

Export and download the image tile cache

Obtain an export and download job by passing the ExportTileCacheParameters to the createExportTileCacheJob() method on the ExportTileCacheTask class. Run the job to download the tile cache into a tile package that is placed in the download path on the device.

Use dark colors for code blocksCopy
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
            val tileCachePath =
                appDataStoragePath + "exportAndDownloadTheImageTileCache.tpk"

            // Get the job.
            val exportTileCacheJob = exportTileCacheTask.createExportTileCacheJob(
                parameters = exportTileCacheParameters,
                downloadFilePath = tileCachePath
            )
            with(lifecycleScope) {
                launch {
                    exportTileCacheJob.progress.collect { progressValue ->
                        logInfo("Progress %: $progressValue")
                    }
                }
                launch {
                    val tileCache = exportTileCacheJob.result().getOrElse { error ->
                        return@launch logErr("The export tile cache job did not return a tile cache: ${error.message}")
                    }
                    tileCache.load().onFailure { error ->
                        return@launch logErr("The export tile cache job did not load: ${error.message}")
                    }

                    // Create a tiled layer from the local cache, then a map using the layer, and display the map.
                    // . . .

                }
            }
            // Run the job.
            if (exportTileCacheJob.start()) {
                logInfo("The export tile cache Job has started.")
            }

The tile cache from an exported basemap tile layer can be used in your map or scene.

Use dark colors for code blocksCopy
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
                    // Create a tiled layer from the local cache, then a map using the layer, and display the map.
                    val tiledLayer = ArcGISTiledLayer(tileCache)
                    // Display the tiled layer as a basemap.
                    val tileCacheMap = ArcGISMap(Basemap(tiledLayer))
                    mapView.map = tileCacheMap
                    tileCacheMap.load().onFailure { error ->
                        return@launch logErr("The tile cache map failed to load: ${error.message}")
                    }

The tile cache from exported elevation data can be used as an elevation source in your scene.

Use dark colors for code blocksCopy
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
                val newScene = ArcGISScene(BasemapStyle.ArcGISImagery)

                // Use the local tile cache to create an ArcGISTiledElevationSource.
                val localElevationSource = ArcGISTiledElevationSource(tileCache)

                // Create a surface. The elevation sources property of a new surface is initially an empty list.
                // Add the local elevation source to the list.
                val elevationSurface = Surface().apply {
                    elevationSources.add(localElevationSource)
                }

                // Set base surface of new scene to the elevation surface. The current base surface will be replaced by your new surface.
                newScene.baseSurface = elevationSurface
                // Attach the new scene to the scene view.
                sceneView.scene = newScene

                //  Set the viewpoint using the camera...

When creating an offline tile cache from a tiled service, consider the following:

  • The export tiles operation used to generate tile caches is only available with services hosted on ArcGIS Server 10.2.1 or later.
  • Estimation of tile cache size is not available on ArcGIS Online hosted tiled services.
  • The time required to create a tile cache varies depending on the extent requested, the number of levels requested, the network connection speed, and so on. Use the createEstimateTileCacheSizeJob() method on the ExportTileCacheTask class, which returns an EstimateTileCacheSizeJob to get the approximate size of a tile cache for a specific set of parameters. Try generating a smaller tile cache to get an idea of how long caching will take when planning a large offline data capture event.
  • There is a limit to the number of tiles you can generate in a single request. When generating a tile cache from an ArcGIS Online basemap, there is a limit of 100,000 tiles per request. Read more on this in the ArcGIS REST API documentation. Organizations that use their own ArcGIS Server to host an offline tile cache can configure the server's maxExportTilesCount via the administrator account to change the default limit of 100,000 tiles.

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