offline
constoffline:object
Defined in: src/offline.ts:21
Take maps and data offline, mirroring ArcGIS.OfflineMapTask and the related export/sync tasks.
Each call is an asynchronous job that downloads files to the app’s storage; pass the returned
path to <Map mobileMapPackagePath> to display a downloaded offline map. Services must be
offline-enabled (sync / exportTiles capability).
Type Declaration
Section titled “Type Declaration”downloadPreplannedOfflineMap
Section titled “downloadPreplannedOfflineMap”downloadPreplannedOfflineMap: (
portalItemId,areaIndex,downloadName) =>Promise<JobRef<OfflineMapResult>>
Downloads a preplanned offline map area (by areaIndex) into a directory named downloadName.
Returns a JobRef — await job.result(), observe onProgress, or job.cancel().
Parameters
Section titled “Parameters”portalItemId
Section titled “portalItemId”string
areaIndex
Section titled “areaIndex”number
downloadName
Section titled “downloadName”string
Returns
Section titled “Returns”Promise<JobRef<OfflineMapResult>>
estimateTileCacheSize
Section titled “estimateTileCacheSize”estimateTileCacheSize: (
tileServiceUrl,areaOfInterest,options?) =>Promise<TileCacheSizeEstimate>
Estimates the on-disk file size and tile count for an exportTileCache download WITHOUT
downloading. Useful for showing the user a preview before committing to a potentially large
download. Returns { fileSize: number, tileCount: number } (fileSize in bytes).
Parameters
Section titled “Parameters”tileServiceUrl
Section titled “tileServiceUrl”string
areaOfInterest
Section titled “areaOfInterest”options?
Section titled “options?”Record<string, unknown>
Returns
Section titled “Returns”Promise<TileCacheSizeEstimate>
exportTileCache
Section titled “exportTileCache”exportTileCache: (
tileServiceUrl,areaOfInterest,downloadName) =>Promise<JobRef<OfflineTileResult>>
Exports a raster tile cache (.tpkx) from a tile service for areaOfInterest.
Parameters
Section titled “Parameters”tileServiceUrl
Section titled “tileServiceUrl”string
areaOfInterest
Section titled “areaOfInterest”downloadName
Section titled “downloadName”string
Returns
Section titled “Returns”Promise<JobRef<OfflineTileResult>>
exportVectorTiles
Section titled “exportVectorTiles”exportVectorTiles: (
vectorTileServiceUrl,areaOfInterest,downloadName) =>Promise<JobRef<OfflineTileResult>>
Exports a vector tile package (.vtpk) from a vector tile service for areaOfInterest.
Parameters
Section titled “Parameters”vectorTileServiceUrl
Section titled “vectorTileServiceUrl”string
areaOfInterest
Section titled “areaOfInterest”downloadName
Section titled “downloadName”string
Returns
Section titled “Returns”Promise<JobRef<OfflineTileResult>>
generateGeodatabase
Section titled “generateGeodatabase”generateGeodatabase: (
featureServiceUrl,extent,downloadName) =>Promise<JobRef<OfflineGeodatabaseResult>>
Generates a .geodatabase from a sync-enabled feature service for extent, downloading it as
downloadName. The returned path can be synced back later with syncGeodatabase.
Parameters
Section titled “Parameters”featureServiceUrl
Section titled “featureServiceUrl”string
extent
Section titled “extent”downloadName
Section titled “downloadName”string
Returns
Section titled “Returns”Promise<JobRef<OfflineGeodatabaseResult>>
generateOfflineMap
Section titled “generateOfflineMap”generateOfflineMap: (
portalItemId,areaOfInterest,downloadName,overrides?) =>Promise<JobRef<OfflineMapResult>>
Takes a web map (portalItemId) offline on-demand for areaOfInterest (an envelope/polygon),
downloading a mobile map package into a directory named downloadName. Returns a JobRef:
await job.result() to run it, job.addListener('onProgress', …) for progress, job.cancel().
Pass optional overrides to narrow the tile-cache scale range and reduce download size:
offline.generateOfflineMap(id, area, 'myMap', { minScale: 0, maxScale: 5000 })See OfflineMapParameterOverrides for details on how minScale/maxScale are applied.
Parameters
Section titled “Parameters”portalItemId
Section titled “portalItemId”string
areaOfInterest
Section titled “areaOfInterest”downloadName
Section titled “downloadName”string
overrides?
Section titled “overrides?”Returns
Section titled “Returns”Promise<JobRef<OfflineMapResult>>
openGeodatabase
Section titled “openGeodatabase”openGeodatabase: (
path) =>Promise<GeodatabaseHandle>
Opens a local mobile geodatabase (.geodatabase file, e.g. from generateGeodatabase) for
transactional editing — wrap edits in beginTransaction then commitTransaction or
rollbackTransaction.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<GeodatabaseHandle>
preplannedMapAreas
Section titled “preplannedMapAreas”preplannedMapAreas: (
portalItemId) =>Promise<PreplannedMapAreaInfo[]>
Lists the preplanned offline map areas published with the web map portalItemId.
Parameters
Section titled “Parameters”portalItemId
Section titled “portalItemId”string
Returns
Section titled “Returns”Promise<PreplannedMapAreaInfo[]>
syncGeodatabase
Section titled “syncGeodatabase”syncGeodatabase: (
geodatabasePath,featureServiceUrl) =>Promise<JobRef<{synced:boolean; }>>
Bidirectionally syncs a downloaded geodatabase with its feature service.
Parameters
Section titled “Parameters”geodatabasePath
Section titled “geodatabasePath”string
featureServiceUrl
Section titled “featureServiceUrl”string
Returns
Section titled “Returns”Promise<JobRef<{ synced: boolean; }>>
syncOfflineMap
Section titled “syncOfflineMap”syncOfflineMap: (
mobileMapPackagePath) =>Promise<JobRef<{synced:boolean; }>>
Syncs a downloaded offline map (.mmpk at mobileMapPackagePath) with its services — pushes
local edits up and pulls server updates down. Returns a JobRef (await job.result()).
Parameters
Section titled “Parameters”mobileMapPackagePath
Section titled “mobileMapPackagePath”string
Returns
Section titled “Returns”Promise<JobRef<{ synced: boolean; }>>