Class OfflineMapTask

  • All Implemented Interfaces:
    RemoteResource, Loadable

    public final class OfflineMapTask
    extends Object
    implements Loadable, RemoteResource
    A task used to take a map offline. Taking a map offline involves downloading all the data for an online map so it can be used offline. When a map is taken offline, it is stored as a mobile map.
    Since:
    100.1.0
    • Method Detail

      • setCredential

        public void setCredential​(Credential credential)
        Sets the credential used to authenticate the user with this task.
        Specified by:
        setCredential in interface RemoteResource
        Parameters:
        credential - the credential used to authenticate the user with this task
        Since:
        100.1.0
      • getCredential

        public Credential getCredential()
        Gets the credential used to authenticate the user with this task.
        Specified by:
        getCredential in interface RemoteResource
        Returns:
        the credential, or null if there is none
        Since:
        100.1.0
      • setRequestConfiguration

        public void setRequestConfiguration​(RequestConfiguration requestConfiguration)
        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 interface RemoteResource
        Parameters:
        requestConfiguration - contains the parameters to use
        Since:
        100.1.0
      • getUri

        public String getUri()
        Gets the URI of this task. This is the URI of the online map.
        Specified by:
        getUri in interface RemoteResource
        Returns:
        the URI of this task; may be null if the task is not loaded
        Since:
        100.1.0
      • getOnlineMap

        public ArcGISMap getOnlineMap()
        Gets the online map associated with this task.
        Returns:
        the online map; may be null if the task is not loaded
        Since:
        100.1.0
      • getPortalItem

        public PortalItem getPortalItem()
        Gets the portal item for the online map associated with this task.
        Returns:
        the portal item
        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 and Polygon. 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
        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:
        Throws:
        IllegalArgumentException - if areaOfInterest is null
        Since:
        100.1.0
        See Also:
        generateOfflineMap(GenerateOfflineMapParameters, String)
      • 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's OfflineSettings (if present).

        Parameters:
        preplannedMapArea - a PreplannedMapArea that defines the region to be taken offline
        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 and Polygon. 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 (see GenerateOfflineMapParameters.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. 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
        minScale - the minimum scale for the offline map and offline tile caches. Use 0 to select all levels of detail that are less detailed than the maxScale.
        maxScale - the maximum scale for the offline map and offline tile caches. Use 0 to select all levels of detail that are more detailed than the minScale.
        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 given GenerateOfflineMapParameters. The overrides may be inspected and modified to change the offline data before creating a job with generateOfflineMap(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 calling get() 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).

        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:
        Throws:
        IllegalArgumentException - if parameters is null
        Since:
        100.4.0
      • getOfflineMapCapabilitiesAsync

        public ListenableFuture<OfflineMapCapabilities> getOfflineMapCapabilitiesAsync​(GenerateOfflineMapParameters parameters)
        Executes an asynchronous operation to get information about which layers in the map can be taken offline. The result is an OfflineMapCapabilities object.
        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:
        Throws:
        IllegalArgumentException - if parameters is null
        Since:
        100.1.0
      • generateOfflineMap

        public GenerateOfflineMapJob generateOfflineMap​(GenerateOfflineMapParameters parameters,
                                                        String downloadDirectoryPath)
        Creates a GenerateOfflineMapJob 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 operation
        downloadDirectoryPath - The path to a folder where the map content is stored on the device. For example, to create a new mobile map package my_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
      • getPreplannedMapAreasAsync

        public ListenableFuture<List<PreplannedMapArea>> 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.
        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:
        Since:
        100.2.0
      • downloadPreplannedOfflineMap

        public DownloadPreplannedOfflineMapJob downloadPreplannedOfflineMap​(PreplannedMapArea area,
                                                                            String downloadDirectoryPath)
        Creates a DownloadPreplannedOfflineMapJob that can be used to download the given preplanned map area of an online map. The job will fail if the last directory in the download directory path cannot be created or is not empty.
        Parameters:
        area - the preplanned map area to be downloaded
        downloadDirectoryPath - The path to a folder where the map content is stored on the device. For example, to create a new mobile map package my_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 area is null, or if downloadDirectoryPath is null or empty
        Since:
        100.2.0
      • downloadPreplannedOfflineMap

        @Deprecated
        public DownloadPreplannedOfflineMapJob downloadPreplannedOfflineMap​(PreplannedMapArea area,
                                                                            String downloadDirectoryPath,
                                                                            boolean excludeBasemap)
        Creates a DownloadPreplannedOfflineMapJob that can be used to download the given preplanned map area of an online map. The job will fail if the last directory in the download directory path cannot be created or is not empty.

        If you exclude the map's basemap from the download the offline map's size will be smaller and consequently the download process will be faster. If you already have a basemap stored locally on your device you can add that to the offline map.

        Parameters:
        area - the preplanned map area to be downloaded
        downloadDirectoryPath - The path to a folder where the map content is stored on the device. For example, to create a new mobile map package my_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.
        excludeBasemap - true to exclude the basemap from the offline map
        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 area is null, or if downloadDirectoryPath is null or empty
        Since:
        100.2.0
      • downloadPreplannedOfflineMap

        public DownloadPreplannedOfflineMapJob downloadPreplannedOfflineMap​(DownloadPreplannedOfflineMapParameters parameters,
                                                                            String downloadDirectoryPath)
        Creates a DownloadPreplannedOfflineMapJob 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 downloaded
        downloadDirectoryPath - The path to a folder where the map content is stored on the device. For example, to create a new mobile map package my_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

        public LoadStatus getLoadStatus()
        Description copied from interface: Loadable
        Returns the LoadStatus of the loadable resource.
        Specified by:
        getLoadStatus in interface Loadable
        Returns:
        the LoadStatus of the loadable resource
      • getLoadError

        public ArcGISRuntimeException getLoadError()
        Description copied from interface: Loadable
        Returns the most recent error that was encountered when the loadable resource transitioned to the LoadStatus.FAILED_TO_LOAD state, either due to calling loadAsync or retryLoadAsync.

        If the resource subsequently transitions to LoadStatus.LOADED, for example if a call to retryLoadAsync completes successfully, the error is cleared out.

        Specified by:
        getLoadError in interface Loadable
        Returns:
        the most recent error that was encountered when the loadable resource transitioned to the LoadStatus.FAILED_TO_LOAD state.
      • cancelLoad

        public void cancelLoad()
        Description copied from interface: Loadable
        Cancels a pending load operation.

        A load operation that is in progress (LoadStatus.LOADING state) can be cancelled by calling this method and the resource will transition from LoadStatus.LOADING to LoadStatus.FAILED_TO_LOAD state. If the load operation was successfully cancelled a CancellationException will be returned from Loadable.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 interface Loadable
      • 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 to LoadStatus.LOADING. A listener can be added via Loadable.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 calling Loadable.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) when loadAsync 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 or LoadStatus.FAILED_TO_LOAD state) when loadAsync 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 calling Loadable.cancelLoad().

        Specified by:
        loadAsync in interface Loadable
      • retryLoadAsync

        public void retryLoadAsync()
        Description copied from interface: Loadable
        Tries to reload the metadata of the loadable resource asynchronously, but only if the resource failed to load previously (LoadStatus.FAILED_TO_LOAD state) or wasn't loaded to begin with ( LoadStatus.NOT_LOADED state).

        For more details on the load process see Loadable.loadAsync().

        Specified by:
        retryLoadAsync in interface Loadable
      • addDoneLoadingListener

        public void addDoneLoadingListener​(Runnable listener)
        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, use the Loadable.addLoadStatusChangedListener(LoadStatusChangedListener) method instead.

        Specified by:
        addDoneLoadingListener in interface Loadable
        Parameters:
        listener - a Runnable that is invoked upon completion of the load operation
      • removeDoneLoadingListener

        public boolean removeDoneLoadingListener​(Runnable listener)
        Description copied from interface: Loadable
        Removes a done loading listener from the loadable resource.
        Specified by:
        removeDoneLoadingListener in interface Loadable
        Parameters:
        listener - the listener to be removed
        Returns:
        true if the listener was removed, otherwise false
      • addLoadStatusChangedListener

        public void addLoadStatusChangedListener​(LoadStatusChangedListener listener)
        Description copied from interface: Loadable
        Adds a LoadStatusChangedListener 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 interface Loadable
        Parameters:
        listener - the LoadStatusChangedListener to be added
      • removeLoadStatusChangedListener

        public boolean removeLoadStatusChangedListener​(LoadStatusChangedListener listener)
        Description copied from interface: Loadable
        Removes a LoadStatusChangedListener from the loadable resource.
        Specified by:
        removeLoadStatusChangedListener in interface Loadable
        Parameters:
        listener - the LoadStatusChangedListener to be removed
        Returns:
        true if the listener was removed, otherwise false