Skip To Content ArcGIS for Developers Sign In Dashboard

OfflineMapTask Class

(Esri::ArcGISRuntime::OfflineMapTask)

A task with methods related to taking a map offline and synchronizing online and offline maps. More...

Header: #include <OfflineMapTask>
Since: Esri::ArcGISRuntime 100.1
Inherits: Object, Loadable, and RemoteResource

Public Functions

OfflineMapTask(Map *onlineMap, Credential *credential, QObject *parent = nullptr)
OfflineMapTask(Map *onlineMap, QObject *parent = nullptr)
OfflineMapTask(PortalItem *portalItem, QObject *parent = nullptr)
~OfflineMapTask()
TaskWatcher createDefaultDownloadPreplannedOfflineMapParameters(PreplannedMapArea *area)
TaskWatcher createDefaultGenerateOfflineMapParameters(const Geometry &areaOfInterest)
TaskWatcher createDefaultGenerateOfflineMapParameters(const Geometry &areaOfInterest, double minScale, double maxScale)
TaskWatcher createGenerateOfflineMapParameterOverrides(const GenerateOfflineMapParameters &parameters)
DownloadPreplannedOfflineMapJob *downloadPreplannedOfflineMap(PreplannedMapArea *area, const QString &downloadDirectoryPath)
DownloadPreplannedOfflineMapJob *downloadPreplannedOfflineMap(const DownloadPreplannedOfflineMapParameters &parameters, const QString &downloadDirectoryPath)
GenerateOfflineMapJob *generateOfflineMap(const GenerateOfflineMapParameters &parameters, const QString &downloadDirectoryPath)
GenerateOfflineMapJob *generateOfflineMap(const GenerateOfflineMapParameters &parameters, const QString &downloadDirectoryPath, GenerateOfflineMapParameterOverrides *parameterOverrides)
TaskWatcher offlineMapCapabilities(const GenerateOfflineMapParameters &parameters)
Map *onlineMap() const
PortalItem *portalItem() const
PreplannedMapAreaListModel *preplannedMapAreaList() const
TaskWatcher preplannedMapAreas()

Reimplemented Public Functions

virtual void cancelLoad()
virtual Credential *credential() const
virtual void load()
virtual Error loadError() const
virtual LoadStatus loadStatus() const
virtual RequestConfiguration requestConfiguration() const
virtual void retryLoad()
virtual void setRequestConfiguration(const RequestConfiguration &requestConfiguration)

Signals

void createDefaultDownloadPreplannedOfflineMapParametersCompleted(QUuid taskId, const Esri::ArcGISRuntime::DownloadPreplannedOfflineMapParameters &parameters)
void createDefaultGenerateOfflineMapParametersCompleted(QUuid taskId, const Esri::ArcGISRuntime::GenerateOfflineMapParameters &parameters)
void createGenerateOfflineMapParameterOverridesCompleted(QUuid taskId, Esri::ArcGISRuntime::GenerateOfflineMapParameterOverrides *parameterOverrides)
void doneLoading(Esri::ArcGISRuntime::Error loadError)
void loadStatusChanged(Esri::ArcGISRuntime::LoadStatus loadStatus)
void offlineMapCapabilitiesCompleted(QUuid taskId, const Esri::ArcGISRuntime::OfflineMapCapabilities &capabilities)
void preplannedMapAreasCompleted(QUuid taskId)

Additional Inherited Members

  • 1 property inherited from QObject
  • 1 public slot inherited from QObject
  • 1 public variable inherited from QObject
  • 10 static public members inherited from QObject
  • 9 protected functions inherited from QObject
  • 2 protected variables inherited from QObject

Detailed Description

A task with methods related to taking a map offline and synchronizing online and offline maps.

Taking a map offline involves downloading an online map and its data, including all the supported layers, tables, renderers, web map configuration, and so on, so that the map may be used offline without a network connection.

There are two workflows available for taking maps offline:

  • the preplanned offline workflow.
  • the on-demand offline workflow.

In the Preplanned offline workflow, the author of an online map can define individual geographical areas called map areas. These map areas prepare map content that is stored online. An app can download that map content to a device using a DownloadPreplannedOfflineMapJob.

In the On-demand offline workflow, the app passes a specific area of interest to a GenerateOfflineMapJob to generate and download the map content to the device.

Member Function Documentation

OfflineMapTask::OfflineMapTask(Map *onlineMap, Credential *credential, QObject *parent = nullptr)

Constructor that accepts an online map, a credential, and a parent object.

  • onlineMap - The online map to take offline.
  • credential - The Credential to use to connect to a secured service.
  • parent - The parent object of this OfflineMapTask.

OfflineMapTask::OfflineMapTask(Map *onlineMap, QObject *parent = nullptr)

Constructor that accepts an online map and a parent object.

  • onlineMap - The online map to take offline.
  • parent - The parent object of this OfflineMapTask.

OfflineMapTask::OfflineMapTask(PortalItem *portalItem, QObject *parent = nullptr)

Constructor that accepts a portal item and a parent object.

  • portalItem - The portal item that is a map to take offline.
  • parent - The parent object of this OfflineMapTask.

The PortalItem must be of type PortalItemType::WebMap - either on ArcGIS Online or an on-premise ArcGIS Enterprise Portal.

OfflineMapTask::~OfflineMapTask()

Destructor.

[virtual] void OfflineMapTask::cancelLoad()

Reimplemented from Loadable::cancelLoad().

See Loadable.

TaskWatcher OfflineMapTask::createDefaultDownloadPreplannedOfflineMapParameters(PreplannedMapArea *area)

Asynchronously retrieves a DownloadPreplannedOfflineMapParameters with default values appropriate for taking the specified area offline.

  • area - The preplanned region of the online map that is to be taken offline.

Returns a TaskWatcher for this asynchronous operation.

If the webmap author has set a reference basemap filename, this will be set into the DownloadPreplannedOfflineMapParameters::referenceBasemapFilename property.

This function was introduced in Esri::ArcGISRuntime 100.5.

[signal] void OfflineMapTask::createDefaultDownloadPreplannedOfflineMapParametersCompleted(QUuid taskId, const Esri::ArcGISRuntime::DownloadPreplannedOfflineMapParameters &parameters)

Emitted when the createDefaultDownloadPreplannedOfflineMapParameters operation completes.

  • taskId - The task ID of the asynchronous operation.
  • parameters - The default parameters returned from the service.

This function was introduced in Esri::ArcGISRuntime 100.5.

TaskWatcher OfflineMapTask::createDefaultGenerateOfflineMapParameters(const Geometry &areaOfInterest)

Asynchronously retrieves a GenerateOfflineMapParameters populated with default settings for a service.

  • areaOfInterest - The geographic area of interest for the offline map.

Returns a TaskWatcher for this asynchronous operation.

This will populate the parameters with default values for all the input parameters defined by the service. If the service defines a default value for a parameter, this will be used. If no default value is defined for a parameter, it will be given an appropriate default for its type: Boolean parameters false, string parameters an empty string, and numerical parameters zero.

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 parameters min scale and max scale are 0, so data will be taken at the full range of scales the services support.

TaskWatcher OfflineMapTask::createDefaultGenerateOfflineMapParameters(const Geometry &areaOfInterest, double minScale, double maxScale)

Asynchronously retrieves a GenerateOfflineMapParameters populated with default settings for a service, created from the specified area of interest, min scale and max scale.

  • areaOfInterest - The geographic area of interest for the offline map.
  • minScale - The minimum scale for the offline map and offline tile caches. Use 0 for all far out levels. Sets the property GenerateOfflineMapParameters::minScale.
  • maxScale - The maximum scale for the offline map and offline tile caches. Use 0 for all closer in detailed levels. Sets the property GenerateOfflineMapParameters::maxScale.

Returns a TaskWatcher for this asynchronous operation.

This will populate the parameters with default values for all the input parameters defined by the service. If the service defines a default value for a parameter, this will be used. If no default value is defined for a parameter, it will be given an appropriate default for its type: Boolean parameters false, string parameters an empty string, and numerical parameters zero.

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 property initialized from the offline map task's portal item, if that is set. The item info's thumbnail will be copied from the portal item's thumbnail.

This function was introduced in Esri::ArcGISRuntime 100.4.

[signal] void OfflineMapTask::createDefaultGenerateOfflineMapParametersCompleted(QUuid taskId, const Esri::ArcGISRuntime::GenerateOfflineMapParameters &parameters)

Emitted when the createDefaultGenerateOfflineMapParameters operation completes.

  • taskId - The task ID of the asynchronous operation.
  • parameters - The default parameters returned from the service.

TaskWatcher OfflineMapTask::createGenerateOfflineMapParameterOverrides(const GenerateOfflineMapParameters &parameters)

Asynchronously retrieves a GenerateOfflineMapParameterOverrides created from the specified parameters.

  • parameters - The generate offline map parameters from which the overrides will be populated.

When the task completes GenerateOfflineMapParameterOverrides will be populated reflecting the values in the GenerateOfflineMapParameters parameters. The overrides may be inspected and modified to change the offline data before passing onto creating a job with OfflineMapTask::generateOfflineMap.

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 this property 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 this property is false, the task will fail with an Error from the failed layer or table.

To check upfront which layers or tables are valid for taking offline, see offlineMapCapabilities.

Returns a TaskWatcher for this asynchronous operation.

If GenerateOfflineMapParameters::referenceBasemapDirectory is set, the overrides corresponding to online basemap layers will be omitted, since no basemap layers will be downloaded.

The returned GenerateOfflineMapParameterOverrides object has the OfflineMapTask as its parent.

This function was introduced in Esri::ArcGISRuntime 100.4.

See also Returned QObjects Parenting.

[signal] void OfflineMapTask::createGenerateOfflineMapParameterOverridesCompleted(QUuid taskId, Esri::ArcGISRuntime::GenerateOfflineMapParameterOverrides *parameterOverrides)

Emitted when the createGenerateOfflineMapParameterOverrides operation completes.

  • taskId - The task ID of the asynchronous operation.
  • parameterOverrides - A set of overrides to allow more fine-grained control of how individual services are taken offline.

This function was introduced in Esri::ArcGISRuntime 100.4.

[virtual] Credential *OfflineMapTask::credential() const

Reimplemented from RemoteResource::credential().

The credential for authenticating against a secured service.

This is only applicable if using a service that is secured.

[signal] void OfflineMapTask::doneLoading(Esri::ArcGISRuntime::Error loadError)

Signal emitted when this object is done loading.

  • loadError Details about any error that may have occurred.

Note: If there is a load error it will also be emitted on the errorOccurred signal.

See also Loadable and Object.

DownloadPreplannedOfflineMapJob *OfflineMapTask::downloadPreplannedOfflineMap(PreplannedMapArea *area, const QString &downloadDirectoryPath)

Returns a job that is used to download the specified preplanned map area of an online map.

  • area - Specifies 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".

Note: The job that is returned is not started and needs to be explicitly started. The job will fail if the last directory in the download directory path cannot be created or is not empty.

This function was introduced in Esri::ArcGISRuntime 100.2.

DownloadPreplannedOfflineMapJob *OfflineMapTask::downloadPreplannedOfflineMap(const DownloadPreplannedOfflineMapParameters &parameters, const QString &downloadDirectoryPath)

Returns a job that is used to download the preplanned map area specified by the given parameters object.

  • 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".

Note: The job that is returned is not started and needs to be explicitly started. The job will fail if the last directory in the download directory path cannot be created or is not empty.

This function was introduced in Esri::ArcGISRuntime 100.4.

GenerateOfflineMapJob *OfflineMapTask::generateOfflineMap(const GenerateOfflineMapParameters &parameters, const QString &downloadDirectoryPath)

Returns a GenerateOfflineMapJob to run this OfflineMapTask.

  • parameters - The set of parameters to use to generate the offline content.
  • 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".

GenerateOfflineMapJob *OfflineMapTask::generateOfflineMap(const GenerateOfflineMapParameters &parameters, const QString &downloadDirectoryPath, GenerateOfflineMapParameterOverrides *parameterOverrides)

Returns a job that is used to generate an offline map using the specified parameters and overrides.

  • parameters - Parameters to specify how to take a map offline. For example, specify the area of interest, min and max scale, layer attachment options. Note that any properties relating to layers should be taken offline will be ignored and the values in the parameterOverrides will be used instead.
  • 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".
  • parameterOverrides - The overrides to the parameters which control how individual services are taken offline. These take precedence over settings in the parameters.

Note: The job that is returned is not started and needs to be explicitly started. The job will fail if the last directory in the download directory path cannot be created or is not empty.

To create an instance GenerateOfflineMapParameterOverrides use createGenerateOfflineMapParameterOverrides. Some properties on GenerateOfflineMapParameters will be ignored when using GenerateOfflineMapParameterOverrides and replaced with equivalent properties for each service. The overridden properties are:

This function was introduced in Esri::ArcGISRuntime 100.4.

[virtual] void OfflineMapTask::load()

Reimplemented from Loadable::load().

See Loadable.

[virtual] Error OfflineMapTask::loadError() const

Reimplemented from Loadable::loadError().

See Loadable.

[virtual] LoadStatus OfflineMapTask::loadStatus() const

Reimplemented from Loadable::loadStatus().

See Loadable.

[signal] void OfflineMapTask::loadStatusChanged(Esri::ArcGISRuntime::LoadStatus loadStatus)

Signal emitted when the load status changes for this object.

See also Loadable.

TaskWatcher OfflineMapTask::offlineMapCapabilities(const GenerateOfflineMapParameters &parameters)

Asynchronously retrieves information about which layers and tables in the map can be taken offline.

  • parameters - The parameters to use to get the offline map capabilities.

Returns a TaskWatcher for this asynchronous operation.

[signal] void OfflineMapTask::offlineMapCapabilitiesCompleted(QUuid taskId, const Esri::ArcGISRuntime::OfflineMapCapabilities &capabilities)

Emitted when the offlineMapCapabilities operation completes.

  • taskId - The task ID of the asynchronous operation.
  • capabilities - The information about which layers and tables in the map can be taken offline.

Map *OfflineMapTask::onlineMap() const

Returns the online map.

PortalItem *OfflineMapTask::portalItem() const

Returns the portal item.

PreplannedMapAreaListModel *OfflineMapTask::preplannedMapAreaList() const

Returns the list of preplanned map areas populated by preplannedMapAreas.

This function was introduced in Esri::ArcGISRuntime 100.2.

See also PreplannedMapArea.

TaskWatcher OfflineMapTask::preplannedMapAreas()

Asynchronously retrieves a list of preplanned map areas, if there are any.

Returns a TaskWatcher for this asynchronous operation.

This function was introduced in Esri::ArcGISRuntime 100.2.

[signal] void OfflineMapTask::preplannedMapAreasCompleted(QUuid taskId)

Emitted when the preplannedMapAreas operation completes.

  • taskId - The task ID of the asynchronous operation.

This function was introduced in Esri::ArcGISRuntime 100.2.

[virtual] RequestConfiguration OfflineMapTask::requestConfiguration() const

Reimplemented from RemoteResource::requestConfiguration().

Returns the configuration parameters used for network requests sent by this task.

See also setRequestConfiguration().

[virtual] void OfflineMapTask::retryLoad()

Reimplemented from Loadable::retryLoad().

See Loadable.

[virtual] void OfflineMapTask::setRequestConfiguration(const RequestConfiguration &requestConfiguration)

Reimplemented from RemoteResource::setRequestConfiguration().

Sets the configuration parameters used for network requests sent by this task to requestConfiguration.

See also requestConfiguration().


Feedback on this topic?