- All Implemented Interfaces:
RemoteResource
,Loadable
There are two workflows available for taking maps offline:
- the ahead-of-time workflow (also sometimes referred to as the preplanned workflow)
- the on-demand workflow
Ahead-of-time workflow - In this workflow the author of a web map defines
geographical areas (offline map areas) to take offline. ArcGIS Online, or ArcGIS Enterprise, uses these to prepare
offline map content that is stored online. Download the offline map content to a device using the
DownloadPreplannedOfflineMapJob
. Note that this API refers to an offline map area as a
PreplannedMapArea
. For more information about authoring offline map areas, see
Take web maps offline.
On-demand workflow - Here the app passes a specific area of interest to a GenerateOfflineMapJob
to
generate and download the map content to the device. Using this workflow, you can choose to keep online only
services (e.g. those that require a network connection) in your offline map. Be aware that an offline map which
uses online only services will require a network connection and may require authentication.
- Since:
- 100.1.0
-
Property Summary
TypePropertyDescriptionThe load error.The load status. -
Constructor Summary
ConstructorDescriptionOfflineMapTask
(ArcGISMap onlineMap) Creates the offline map task for the provided online map.OfflineMapTask
(PortalItem portalItem) Creates the offline map task with the provided portal item. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addDoneLoadingListener
(Runnable listener) Adds a listener to the loadable resource that is invoked when loading has completed.void
Adds aLoadStatusChangedListener
to the loadable resource that is invoked whenever the load status changes.void
Cancels loading metadata for the object.createDefaultDownloadPreplannedOfflineMapParametersAsync
(PreplannedMapArea preplannedMapArea) Executes an asynchronous operation to create a DownloadPreplannedOfflineMapParameters from the specified PreplannedMapArea.createDefaultGenerateOfflineMapParametersAsync
(Geometry areaOfInterest) Executes an asynchronous operation to create a set of default parameters that can be used to take an online map offline.createDefaultGenerateOfflineMapParametersAsync
(Geometry areaOfInterest, double minScale, double maxScale) Executes an asynchronous operation to create a GenerateOfflineMapParameters from the specified area of interest, min scale, and max scale.Executes an asynchronous operation to create a GenerateOfflineMapParameterOverrides object that is populated to reflect the values in the provided GenerateOfflineMapParameters.downloadPreplannedOfflineMap
(DownloadPreplannedOfflineMapParameters parameters, String downloadDirectoryPath) Creates aDownloadPreplannedOfflineMapJob
that can be used to download the preplanned map area specified by the given parameters object.generateOfflineMap
(GenerateOfflineMapParameters parameters, String downloadDirectoryPath) Creates aGenerateOfflineMapJob
that can be used to generate an offline map from an online map, using the specified parameters.generateOfflineMap
(GenerateOfflineMapParameters parameters, String downloadDirectoryPath, GenerateOfflineMapParameterOverrides parameterOverrides) Creates aGenerateOfflineMapJob
that can be used to generate an offline map from an online map, using the specified parameters and overrides.Gets the credential used to authenticate the user with this task.Gets the value of theloadError
property.Gets the value of theloadStatus
property.Executes an asynchronous operation to get theOfflineMapCapabilities
containing information on which layers will be included in an offline map.Gets the online map associated with this task.Gets the portal item for the online map associated with this task.Executes an asynchronous operation to get a list of preplanned map areas.Gets the RequestConfiguration object in use by this task.getUri()
Gets the URI of this task.void
Loads the metadata of the loadable resource asynchronously.The load error.The load status.boolean
removeDoneLoadingListener
(Runnable listener) Removes a done loading listener from the loadable resource.boolean
Removes aLoadStatusChangedListener
from the loadable resource.void
Loads or retries loading metadata for the object asynchronously.void
setCredential
(Credential credential) Sets the credential used to authenticate the user with this task.void
setRequestConfiguration
(RequestConfiguration requestConfiguration) Sets configuration parameters used for network requests sent using this task.
-
Property Details
-
loadStatus
- Specified by:
loadStatusProperty
in interfaceLoadable
- Returns:
- the
loadStatus
property - See Also:
-
loadError
- Specified by:
loadErrorProperty
in interfaceLoadable
- Returns:
- the
loadError
property - See Also:
-
-
Constructor Details
-
OfflineMapTask
Creates the offline map task for the provided online map. The online map must represent a web map.The online map must be of type
PortalItem.Type.WEBMAP
, either on ArcGIS Online or an on-premise ArcGIS Enterprise Portal.- Parameters:
onlineMap
- an ArcGISMap that represents a web map- Throws:
IllegalArgumentException
- if onlineMap is nullIllegalArgumentException
- if onlineMap is not a web map- Since:
- 100.1.0
-
OfflineMapTask
Creates the offline map task with the provided portal item. The portal item must represent a web map.The
PortalItem
must be of typePortalItem.Type.WEBMAP
, either on ArcGIS Online or an on-premise ArcGIS Enterprise Portal.- Parameters:
portalItem
- a portal item that represents a web map- Throws:
IllegalArgumentException
- if portalItem is null- Since:
- 100.1.0
- See Also:
-
-
Method Details
-
setCredential
Sets the credential used to authenticate the user with this task.- Specified by:
setCredential
in interfaceRemoteResource
- Parameters:
credential
- the credential used to authenticate the user with this task- Since:
- 100.1.0
-
getCredential
Gets the credential used to authenticate the user with this task.- Specified by:
getCredential
in interfaceRemoteResource
- Returns:
- the credential, or null if there is none
- Since:
- 100.1.0
-
setRequestConfiguration
Sets configuration parameters used for network requests sent using this task. The global RequestConfiguration is used if no RequestConfiguration is set.- Specified by:
setRequestConfiguration
in interfaceRemoteResource
- Parameters:
requestConfiguration
- contains the parameters to use- Since:
- 100.1.0
-
getRequestConfiguration
Gets the RequestConfiguration object in use by this task.- Specified by:
getRequestConfiguration
in interfaceRemoteResource
- Returns:
- the RequestConfiguration object, or null if none has been set
- Since:
- 100.1.0
- See Also:
-
getUri
Gets the URI of this task. This is the URI of the online map.- Specified by:
getUri
in interfaceRemoteResource
- Returns:
- the URI of this task; may be null if the task is not loaded
- Since:
- 100.1.0
-
getOnlineMap
Gets the online map associated with this task.The online map will be of type
PortalItem.Type.WEBMAP
, either on ArcGIS Online or an on-premise ArcGIS Enterprise Portal.- Returns:
- the online map; may be null if the task is not loaded
- Since:
- 100.1.0
-
getPortalItem
Gets the portal item for the online map associated with this task.The
PortalItem
will be of typePortalItem.Type.WEBMAP
, either on ArcGIS Online or an on-premise ArcGIS Enterprise Portal.- Returns:
- the portal item, or null if none
- Since:
- 100.1.0
-
createDefaultGenerateOfflineMapParametersAsync
public ListenableFuture<GenerateOfflineMapParameters> createDefaultGenerateOfflineMapParametersAsync(Geometry areaOfInterest) Executes an asynchronous operation to create a set of default parameters that can be used to take an online map offline. The result is a GenerateOfflineMapParameters object.The supported geometry types for the area of interest are
Envelope
andPolygon
. The area of interest must have a spatial reference.Where a
Polygon
is supplied, features and tiles will be filtered according to the polygon geometry, which can help reduce the size of the resulting offline map. Note that the filtered set of tiles may vary, depending on the underlying service.In the resultant GenerateOfflineMapParameters:
- minScale and maxScale are zero, which will cause the full range of scales supported by the service to be taken offline
- the itemInfo is initialized from the offline map task's portal item
- the itemInfo's thumbnail is copied from the portal item's thumbnail
If the map being taken offline contains a
UtilityNetwork
and is in an ArcGIS Enterprise 11.1 or later service, the Offline Capability selected for theUtilityNetwork
such as "Trace utility network features" will automatically be reflected in the default parameters created by this method. If the map being taken offline contains anUtilityNetwork
and is in an earlier version of ArcGIS Enterprise, theGenerateGeodatabaseParameters.getUtilityNetworkSyncMode()
is set toUtilityNetworkSyncMode.SYNC_SYSTEM_TABLES
for theGeodatabase
containing theUtilityNetwork
. UsecreateGenerateOfflineMapParameterOverridesAsync(GenerateOfflineMapParameters)
to change theUtilityNetworkSyncMode
if desired.- Parameters:
areaOfInterest
- the region of the online map that is to be taken offline; must be an Envelope or a Polygon and must have a spatial reference- Returns:
- a ListenableFuture for tracking when the operation is done and getting the result; also allows
cancellation. Calling
get()
on the returned future may throw an ExecutionException with its cause set to:IOException
if a network request fails
- Throws:
IllegalArgumentException
- if areaOfInterest is null- Since:
- 100.1.0
- See Also:
-
createDefaultDownloadPreplannedOfflineMapParametersAsync
public ListenableFuture<DownloadPreplannedOfflineMapParameters> createDefaultDownloadPreplannedOfflineMapParametersAsync(PreplannedMapArea preplannedMapArea) Executes an asynchronous operation to create a DownloadPreplannedOfflineMapParameters from the specified PreplannedMapArea.A convenience method to create
DownloadPreplannedOfflineMapParameters
with default values appropriate for taking the specified map area offline. The parameters will be populated using the values in the online map'sOfflineSettings
(if present).- Parameters:
preplannedMapArea
- the offline map area that is to be downloaded from the online map- Returns:
- a ListenableFuture for tracking when the operation is done and getting the result
- Throws:
IllegalArgumentException
- if preplannedMapArea is null- Since:
- 100.5.0
-
createDefaultGenerateOfflineMapParametersAsync
public ListenableFuture<GenerateOfflineMapParameters> createDefaultGenerateOfflineMapParametersAsync(Geometry areaOfInterest, double minScale, double maxScale) Executes an asynchronous operation to create a GenerateOfflineMapParameters from the specified area of interest, min scale, and max scale.The supported geometry types for the area of interest are
Envelope
andPolygon
. The area of interest must have a spatial reference.Where a
Polygon
is supplied, features and tiles will be filtered according to the polygon geometry, which can help reduce the size of the resulting offline map. Note that the filtered set of tiles may vary, depending on the underlying service.The returned
GenerateOfflineMapParameters
has its ItemInfo (seeGenerateOfflineMapParameters.getItemInfo()
) property initialized from the offline map task's portal item, if that is set. The ItemInfo's thumbnail will be copied from the portal item's thumbnail.If the online map contains an
UtilityNetwork
in theArcGISMap.getUtilityNetworks()
, theGenerateGeodatabaseParameters.getUtilityNetworkSyncMode()
property is set toUtilityNetworkSyncMode.SYNC_SYSTEM_TABLES
. This will include all the data layers and tables in the feature service in theGenerateGeodatabaseParameters.getLayerOptions()
. The feature data of each layer or table is filtered by an area of interest if they are already part of the map, or byGenerateLayerOption.QueryOption.NONE
if they are not. This allows theUtilityNetwork
to query associations offline. To also enable tracing offline, you may use the result ofcreateGenerateOfflineMapParameterOverridesAsync(GenerateOfflineMapParameters)
to explicitly setGenerateGeodatabaseParameters.getUtilityNetworkSyncMode()
toUtilityNetworkSyncMode.SYNC_SYSTEM_AND_TOPOLOGY_TABLES
. Alternatively, you may setGenerateGeodatabaseParameters.getUtilityNetworkSyncMode()
toUtilityNetworkSyncMode.NONE
or clearArcGISMap.getUtilityNetworks()
before calling this method to opt-out of the necessary and automatic inclusion of data or system layers that permit anUtilityNetwork
to function offline.The default parameters will be populated using the values in the online map's
OfflineSettings
(if present).- Parameters:
areaOfInterest
- a Geometry defining the area of interest; must be an Envelope or a Polygon and must have a spatial reference. SeeGenerateOfflineMapParameters.setAreaOfInterest(Geometry)
.minScale
- the minimum scale for offline tile caches. Use 0 to select all far out levels (those which are less detailed than the maxScale). SeeGenerateOfflineMapParameters.setMinScale(double)
.maxScale
- the maximum scale for offline tile caches. Use 0 to select all closer in levels (those which are more detailed than the minScale). SeeGenerateOfflineMapParameters.setMaxScale(double)
.- Returns:
- a ListenableFuture for tracking when the operation is done and getting the result
- Throws:
IllegalArgumentException
- if areaOfInterest is null, or minScale or maxScale is negative- Since:
- 100.5.0
-
createGenerateOfflineMapParameterOverridesAsync
public ListenableFuture<GenerateOfflineMapParameterOverrides> createGenerateOfflineMapParameterOverridesAsync(GenerateOfflineMapParameters parameters) Executes an asynchronous operation to create a GenerateOfflineMapParameterOverrides object that is populated to reflect the values in the provided GenerateOfflineMapParameters. The overrides may be inspected and modified to change the offline data before creating a job withgenerateOfflineMap(GenerateOfflineMapParameters, String, GenerateOfflineMapParameterOverrides)
.If there are errors with loading individual layers or tables, or they cannot be taken offline due to service settings, the outcome depends on the value of
GenerateOfflineMapParameters.isContinueOnErrors()
:- If
isContinueOnErrors
is true, the overrides correspond to the remaining layers and tables that can go offline. The resulting offline map will not contain the layers or tables which had errors. - If
isContinueOnErrors
is false, this operation will fail and callingget()
on the returned future will throw an ExecutionException with its cause set to the layer or table error that caused the failure.
To check upfront which layers or tables are valid for taking offline see
getOfflineMapCapabilitiesAsync(GenerateOfflineMapParameters)
.If the reference basemap directory is set (see
GenerateOfflineMapParameters.setReferenceBasemapDirectory(String)
), the overrides corresponding to online basemap layers will be omitted, since no basemap layers will be downloaded.- Parameters:
parameters
- the GenerateOfflineMapParameters from which the overrides will be populated- Returns:
- a ListenableFuture for tracking when the operation is done and getting the result; also allows
cancellation. Calling
get()
on the returned future may throw an ExecutionException with its cause set to:IOException
if a network request fails
- Throws:
IllegalArgumentException
- if parameters is null- Since:
- 100.4.0
- If
-
getOfflineMapCapabilitiesAsync
public ListenableFuture<OfflineMapCapabilities> getOfflineMapCapabilitiesAsync(GenerateOfflineMapParameters parameters) Executes an asynchronous operation to get theOfflineMapCapabilities
containing information on which layers will be included in an offline map.- Parameters:
parameters
- the parameters to be used for taking the map offline- Returns:
- a ListenableFuture for tracking when the operation is done and getting the result; also allows
cancellation. Calling
get()
on the returned future may throw an ExecutionException with its cause set to:IOException
if a network request fails
- Throws:
IllegalArgumentException
- if parameters is null- Since:
- 100.1.0
-
generateOfflineMap
public GenerateOfflineMapJob generateOfflineMap(GenerateOfflineMapParameters parameters, String downloadDirectoryPath) Creates aGenerateOfflineMapJob
that can be used to generate an offline map from an online map, using the specified parameters. The job will fail if the last directory in the download directory path cannot be created or is not empty.- Parameters:
parameters
- the parameters to be used for the generate offline map operationdownloadDirectoryPath
- The path to a folder where the map content is stored on the device. For example, to create a new mobile map packagemy_mobile_map_package
in a parent directory[my root path]/my_mobile_maps
, this property would be[my root path]/my_mobile_maps/my_mobile_map_package
.- Returns:
- a GenerateOfflineMapJob that will generate the offline map. The result is a GenerateOfflineMapResult object
if the job completed successfully. Note you must call
Job.start()
to start the Job. - Throws:
IllegalArgumentException
- if parameters is null, or if downloadDirectoryPath is null or empty- Since:
- 100.1.0
-
generateOfflineMap
public GenerateOfflineMapJob generateOfflineMap(GenerateOfflineMapParameters parameters, String downloadDirectoryPath, GenerateOfflineMapParameterOverrides parameterOverrides) Creates aGenerateOfflineMapJob
that can be used to generate an offline map from an online map, using the specified parameters and overrides. The job will fail if the last directory in the download directory path cannot be created or is not empty.The
GenerateOfflineMapParameterOverrides
allows more control over the extracted data. UsecreateGenerateOfflineMapParameterOverridesAsync(GenerateOfflineMapParameters)
to create an instance ofGenerateOfflineMapParameterOverrides
.Some properties on GenerateOfflineMapParameters will be ignored when using GenerateOfflineMapParameterOverrides and replaced with equivalent properties for each service. The overridden properties are:
GenerateOfflineMapParameters.isIncludeBasemap()
GenerateOfflineMapParameters.getReturnLayerAttachmentOption()
GenerateOfflineMapParameters.getAttachmentSyncDirection()
GenerateOfflineMapParameters.isReturnSchemaOnlyForEditableLayers()
GenerateOfflineMapParameters.isDefinitionExpressionFilterEnabled()
GenerateOfflineMapParameters.getOnlineOnlyServicesOption()
- Parameters:
parameters
- the parameters to be used for the generate offline map operationdownloadDirectoryPath
- The path to a folder where the map content is stored on the device. For example, to create a new mobile map packagemy_mobile_map_package
in a parent directory[my root path]/my_mobile_maps
, this property would be[my root path]/my_mobile_maps/my_mobile_map_package
.parameterOverrides
- the overrides to the parameters- Returns:
- a GenerateOfflineMapJob that will generate the offline map. The result is a GenerateOfflineMapResult object
if the job completed successfully. Note you must call
Job.start()
to start the Job. - Throws:
IllegalArgumentException
- if parameters or parameterOverrides is null, or if downloadDirectoryPath is null or empty- Since:
- 100.4.0
-
getPreplannedMapAreasAsync
Executes an asynchronous operation to get a list of preplanned map areas. The result is an unmodifiable list of PreplannedMapArea objects, which is empty if there are no preplanned areas for this map.Note that calling this method will load the OfflineMapTask if it is not already loaded.
- Returns:
- a ListenableFuture for tracking when the operation is done and getting the result; also allows
cancellation. Calling
get()
on the returned future may throw an ExecutionException with its cause set to:IOException
if a network request fails
- Since:
- 100.2.0
-
downloadPreplannedOfflineMap
public DownloadPreplannedOfflineMapJob downloadPreplannedOfflineMap(DownloadPreplannedOfflineMapParameters parameters, String downloadDirectoryPath) Creates aDownloadPreplannedOfflineMapJob
that can be used to download the preplanned map area specified by the given parameters object. The job will fail if the last directory in the download directory path cannot be created or is not empty.- Parameters:
parameters
- specifies parameters for the job including the preplanned map area to be downloadeddownloadDirectoryPath
- The path to a folder where the map content is stored on the device. For example, to create a new mobile map packagemy_mobile_map_package
in a parent directory[my root path]/my_mobile_maps
, this property would be[my root path]/my_mobile_maps/my_mobile_map_package
.- Returns:
- a DownloadPreplannedOfflineMapJob that will download the preplanned map area. The result is a
DownloadPreplannedOfflineMapResult object if the job completed successfully. Note you must call
Job.start()
to start the Job. - Throws:
IllegalArgumentException
- if parameters is null, or if downloadDirectoryPath is null or empty- Since:
- 100.4.0
-
getLoadStatus
Gets the value of theloadStatus
property.- Specified by:
getLoadStatus
in interfaceLoadable
- Property description:
- Returns:
- the value of the
loadStatus
property - See Also:
-
getLoadError
Gets the value of theloadError
property.- Specified by:
getLoadError
in interfaceLoadable
- Property description:
- Returns:
- the value of the
loadError
property - See Also:
-
cancelLoad
public void cancelLoad()Description copied from interface:Loadable
Cancels loading metadata for the object.Cancels loading the metadata if the object is loading, and always invokes the done loading listener.
A load operation that is in progress (
LoadStatus.LOADING
state) can be cancelled by calling this method and the resource will transition fromLoadStatus.LOADING
toLoadStatus.FAILED_TO_LOAD
state. If the load operation was successfully cancelled, a CancellationException will be returned fromLoadable.getLoadError()
.Cancellation should be used carefully because all enqueued done loading listeners for that resource instance will get invoked with an error stating that the operation was cancelled. Thus, one component in the application can cancel the load operation initiated by other components.
This method does nothing if the resource is not in
LoadStatus.LOADING
state.- Specified by:
cancelLoad
in interfaceLoadable
-
loadAsync
public void loadAsync()Description copied from interface:Loadable
Loads the metadata of the loadable resource asynchronously.The load status changes from
LoadStatus.NOT_LOADED
toLoadStatus.LOADING
. A listener can be added viaLoadable.addDoneLoadingListener(java.lang.Runnable)
that is invoked upon completion of the asynchronous load operation.If the load operation completes successfully, the load status will be
LoadStatus.LOADED
, which means the resource has loaded its metadata.If the load operation failed, the load status will be
LoadStatus.FAILED_TO_LOAD
and the error can be retrieved by callingLoadable.getLoadError()
.This method can be called concurrently and repeatedly, but only one attempt is ever made to perform the load operation. If a load operation is already in progress (
LoadStatus.LOADING
state) whenloadAsync
is called, it simply piggy-backs on the outstanding operation and the done loading listener added to the loadable resource is enqueued to be invoked when that operation completes. If the operation has already completed (LoadStatus.LOADED
orLoadStatus.FAILED_TO_LOAD
state) whenloadAsync
is called, the done loading listener is immediately invoked when added to the loadable resource.If a loadable resource has failed to load, calling
loadAsync
on it subsequently will not change its state. The done loading listener will be invoked immediately when added to the loadable resource. In order to retry loading the resource,Loadable.retryLoadAsync()
needs to be used.A load operation that is in progress (
LoadStatus.LOADING
state) can be cancelled by callingLoadable.cancelLoad()
. -
retryLoadAsync
public void retryLoadAsync()Description copied from interface:Loadable
Loads or retries loading metadata for the object asynchronously.Will retry loading the metadata if the object's load status is
LoadStatus.FAILED_TO_LOAD
. Will load the object if it is not loaded. Will not retry to load the object if the object is loaded.For more details on the load process see
Loadable.loadAsync()
.- Specified by:
retryLoadAsync
in interfaceLoadable
-
addDoneLoadingListener
Description copied from interface:Loadable
Adds a listener to the loadable resource that is invoked when loading has completed.The listener may be added at any point, whether the loadable resource has already completed loading or not.
- For resources that are not loaded when the listener is added (LoadStatus is NOT_LOADED or LOADING): When the resource completes loading, the listener will be invoked on the UI thread if it is added from the UI thread, otherwise it is not guaranteed on which thread the listener is invoked.
- For resources that are already loaded when the listener is added (LoadStatus is LOADED or FAILED_TO_LOAD): The listener will be called immediately, on the current thread.
Alternatively, to be notified when there is any change in the load status, add a listener to the
Loadable.loadStatusProperty()
instead.- Specified by:
addDoneLoadingListener
in interfaceLoadable
- Parameters:
listener
- a Runnable that is invoked upon completion of the load operation
-
removeDoneLoadingListener
Description copied from interface:Loadable
Removes a done loading listener from the loadable resource.- Specified by:
removeDoneLoadingListener
in interfaceLoadable
- Parameters:
listener
- the listener to be removed- Returns:
- true if the listener was removed, otherwise false
-
addLoadStatusChangedListener
Description copied from interface:Loadable
Adds aLoadStatusChangedListener
to the loadable resource that is invoked whenever the load status changes.Adding this listener on the UI thread will cause it to be invoked on the UI thread, otherwise it is not guaranteed on which thread the listener is invoked.
The listener will not be called if added to a loadable resource that has already completed loading. To be notified when a loadable resource has completed loading, including if the resource is already loaded when the listener is added, use the
Loadable.addDoneLoadingListener(Runnable)
method.- Specified by:
addLoadStatusChangedListener
in interfaceLoadable
- Parameters:
listener
- theLoadStatusChangedListener
to be added
-
removeLoadStatusChangedListener
Description copied from interface:Loadable
Removes aLoadStatusChangedListener
from the loadable resource.- Specified by:
removeLoadStatusChangedListener
in interfaceLoadable
- Parameters:
listener
- theLoadStatusChangedListener
to be removed- Returns:
- true if the listener was removed, otherwise false
-
loadStatusProperty
Description copied from interface:Loadable
The load status.- Specified by:
loadStatusProperty
in interfaceLoadable
- Returns:
- the
loadStatus
property - See Also:
-
loadErrorProperty
Description copied from interface:Loadable
The load error.- Specified by:
loadErrorProperty
in interfaceLoadable
- Returns:
- the
loadError
property - See Also:
-