ArcGIS Runtime SDK for iOS: AGSMobileMapPackage Class Reference
ArcGIS Runtime SDK for iOS  100.15
AGSMobileMapPackage Class Reference

Description

A mobile map package.

Mobile map packages allow you to work with maps on a mobile device.

A mobile map package contains all of the files necessary to work with your maps and is stored on a device as either:

  • A single archive file with an .mmpk extension
  • A directory containing an unpacked mobile map package

You can create a mobile map package using either:

A mobile map package can encapsulate one or more maps along with their layers and data. Each package contains an AGSItem object with metadata about the package (description, thumbnail, etc.).

Mobile map packages created with ArcGIS Pro can also include transportation networks, locators, and links to online services.

You can choose whether to use:

  • A tile package (such as .tpk, .tpkx or .vtpk) or an online basemap as the AGSMap::basemap property.
  • A mobile geodatabase (.geodatabase) or an online feature service as the AGSGeoModel::operationalLayers property. Online services (such as traffic or weather) can provide excellent contextual information for your users. If the mobile map package is going to be used in areas of poor connectivity, however, you must ensure that data critical to your workflow is stored locally on the device.

Mobile map packages implement the AGSLoadable interface; you need to load the AGSMobileMapPackage object before you can access its content.

Once loaded you can:

  • Determine the version of this package using the AGSMobileMapPackage::version property. ArcGIS Runtime currently supports mobile map packages up to and including major version 5. If the package is from an unsupported version, it will fail to load.
  • Discover whether the mobile map package has expired using the AGSMobileMapPackage::expiration property
  • Access the individual maps and display them in an AGSMapView object
  • Programmatically add, modify, and remove layers in the map. Mobile map packages, however, are read-only and these changes to maps or layers are not persisted.
    Since
    100
    License Restrictions:
    This feature requires a StreetMap extension for production deployment when opening StreetMap Premium mobile map package . No license required in Developer mode for testing.
Inheritance diagram for AGSMobileMapPackage:
AGSLoadableBase AGSObject <AGSLoadable>

Instance Methods

(void) - cancelLoad
 
(void) - close
 
(void) - doCancelLoading
 
(void) - doStartLoading:
 
(instancetype) - initWithFileURL:
 
(instancetype) - initWithName:
 
(void) - loadDidFinishWithError:
 
(void) - loadWithCompletion:
 
(void) - onLoadStatusChanged
 
(void) - retryLoadWithCompletion:
 

Class Methods

(id< AGSCancelable >) + checkDirectReadSupportForMobileMapPackageAtFileURL:completion:
 
(instancetype) + mobileMapPackageWithFileURL:
 
(instancetype) + mobileMapPackageWithName:
 
(id< AGSCancelable >) + unpackMobileMapPackageAtFileURL:outputDirectory:completion:
 

Properties

AGSExpirationexpiration
 
NSURL * fileURL
 
AGSItemitem
 
NSError * loadError
 
AGSLoadStatus loadStatus
 
AGSLocatorTasklocatorTask
 
NSArray< AGSMap * > * maps
 
NSString * version
 

Method Documentation

◆ cancelLoad

- (void) cancelLoad
requiredinherited

Cancels loading if it is in progress, otherwise it does nothing. This should be called carefully because other objects could be waiting for loadWithCompletion: or retryLoadWithCompletion: to complete and this will call them all back with the error of NSUserCancelledError

Since
100

◆ checkDirectReadSupportForMobileMapPackageAtFileURL:completion:

+ (id<AGSCancelable>) checkDirectReadSupportForMobileMapPackageAtFileURL: (NSURL *)  fileURL
completion: (void(^)(BOOL isDirectReadSupported, NSError *__nullable error))  completion 

Checks if the package can be read directly without requiring to be unpacked. isDirectReadSupported will always be YES after deprecation in version 100.7.

Prior to ArcGIS Runtime version 100.7, some data formats (such as AGSRasterLayer) could only be accessed if they were unpacked from the mobile map package file (.mmpk). In these situations, isDirectReadSupported would be NO and you would need to call the AGSMobileMapPackage::unpackWithMobileMapPackageFileURL:outputDirectory:completion: to unpack the mmpk.

From version 100.7 and onwards this limitation has been removed allowing the data to be read directly from the mobile map package file. isDirectReadSupported is always YES.

Since this method is no longer required it can be removed from calling code including any subsequent use of AGSMobileMapPackage::unpackWithMobileMapPackageFileURL:outputDirectory:completion:.

Parameters
fileURLA file URL to the mmpk file.
completionA block that is invoked with information about whether direct read is supported if the operation succeeds, or an error if it fails.
Returns
An operation that can be canceled.
See also
AGSMobileMapPackage::unpackWithMobileMapPackageFileURL:outputDirectory:completion:
Since
100.2.1
Deprecated:
100.7 This method is no longer required as the result is always true. It can be removed from calling code including any subsequent use of AGSMobileMapPackage::unpackWithMobileMapPackageFileURL:outputDirectory:completion:.

Provided by category AGSMobileMapPackage(AGSDeprecated).

◆ close

- (void) close

Closes a mobile map package.

Closes a mobile map package and frees file locks on the underlying .mmpk file or directory.

All references to mobile map package data (maps, layers, tables, networks, locators, etc.) should be released before closing the package. If active references to mobile map package data exist, this method will still close the package, but subsequent rendering and data access methods will fail. Results of accessing mobile map package data after closing it are undefined.

After closing a mobile map package, the underlying .mmpk file or directory can be moved or deleted.

Closing a mobile map package is not necessary if the package has not been loaded.

See also
- close (AGSGeodatabase)
Since
100.6

◆ doCancelLoading

- (void) doCancelLoading

Never call this method directly. The framework calls this method on a background thread when cancelLoad (AGSLoadable-p) is called. It is meant to be overriden by subclasses. Subclasses should override this method to cancel loading their data and call loadDidFinishWithError: (AGSLoadableBase(ForSubclassEyesOnly)) at the end passing in an error representing NSUserCancelledError.

Since
100

Provided by category AGSLoadableBase(ForSubclassEyesOnly).

◆ doStartLoading:

- (void) doStartLoading: (BOOL)  retrying

Never call this method directly. The framework calls this method on a background thread when loadWithCompletion: (AGSLoadable-p) or retryLoadWithCompletion: (AGSLoadable-p) is called. It is meant to be overriden by subclasses. Subclasses should override this method to load their data and call loadDidFinishWithError: (AGSLoadableBase(ForSubclassEyesOnly)) upon completion, passing in the error if any.

Parameters
retryingflag that is true if this method was called from retryLoadWithCompletion: (AGSLoadable-p).
Since
100

Provided by category AGSLoadableBase(ForSubclassEyesOnly).

◆ loadDidFinishWithError:

- (void) loadDidFinishWithError: (nullable NSError *)  error

Only subclasses should call this method in doStartLoading: (AGSLoadableBase(ForSubclassEyesOnly)) and doCancelLoading (AGSLoadableBase(ForSubclassEyesOnly)) when done loading or failed to load.

Since
100

Provided by category AGSLoadableBase(ForSubclassEyesOnly).

◆ loadWithCompletion:

- (void) loadWithCompletion: (nullable void(^)(NSError *__nullable error))  completion
requiredinherited

Loads data for the object asynchronously. The completion block is invoked upon completion.

You can call this method any number of times, however only one attempt is made to load the data. If it is already loading, it will just continue to load (i.e. not force a reload). If it has already loaded successfully, the completion block will be invoked right away. If it has already failed to load, the completion block will be invoked right away with error previously encountered. This method supports multiple callers and will call them all back on completion. However, each caller's completion block will be invoked once and only once.

Parameters
completionblock that is invoked when object loads successfully or fails to load. An error is passed to the block if the object fails to load.
Note
The completion block is always invoked on the main thread.
Since
100
See also
- cancelLoad to cancel loading
- retryLoadWithCompletion: to force reload

◆ onLoadStatusChanged

- (void) onLoadStatusChanged

Never call this method directly. The framework calls this method on a background thread when AGSLoadable::loadStatus changes is called. Subclasses can optionally implement this to know when their loading status has changed.

Since
100

Provided by category AGSLoadableBase(ForSubclassEyesOnly).

◆ retryLoadWithCompletion:

- (void) retryLoadWithCompletion: (nullable void(^)(NSError *__nullable error))  completion
requiredinherited

Tries to reload when an object has failed to load. This method should be called judiciously. It should be called when:

  1. you didn't have network connectivity earlier when it failed and you want to retry now that you have connectivity
  2. the server was down earlier when it failed and you want to retry
  3. the request is taking too long and you want to cancel it and retry, in which case you will first call cancelLoad and then this method

If the data hasn't started loading, it will start loading. If it is already loading, it will just continue to load. If it has already loaded successfully, calls back right away. If it has already failed to load, tries again. This method supports multiple callers and will call them all back on completion. However, each caller's completion block will be invoked once and only once.

Parameters
completionblock that is invoked when object loads successfully or fails to load. An error is passed to the block if the object fails to load.
Note
The completion block is always invoked on the main thread.
Since
100

◆ unpackMobileMapPackageAtFileURL:outputDirectory:completion:

+ (id<AGSCancelable>) unpackMobileMapPackageAtFileURL: (NSURL *)  fileURL
outputDirectory: (NSURL *)  outputDirectory
completion: (void(^)(NSError *__nullable error))  completion 

Unpacks a mobile map package file (.mmpk) to the specified directory. Note that unpacking will fail if the package is expired and was authored as AGSExpirationTypePreventExpiredAccess.

Parameters
fileURLA file URL to the mmpk file.
outputDirectoryAn output directory specifying where to unpack the package. If the last component of the directory location does not exist, it will be created during unpacking.
completionA block that is invoked when the operation completes.
Returns
An operation that can be canceled.
Since
100.2.1

Property Documentation

◆ expiration

- (AGSExpiration*) expiration
readnonatomicstrong

Expiration details for this mobile map package, if provided.

Expiration details provide:

  • The package’s expiration date and time
  • Whether the maps can be accessed after expiration
  • Any messages relevant for the user

These expiration details can be specified when the author creates a mobile map package using ArcGIS Pro (from version 2.4). This requires the ArcGIS Pro Publisher Extension. Mobile map packages created with the AGSOfflineMapTask object do not support expiration.

By publishing a package with expiration details, the author can control the experience an end-user has when they try to access information that is no longer valid. For example, for time limited data (such as major sporting events), the author can ensure that the data cannot be accessed after the expiry date.

During package loading, the ArcGIS Runtime will determine whether the mobile map package was authored with expiration. If so, then this property will be populated.

If the package has expired and was authored as AGSExpirationTypePreventExpiredAccess, loading will fail and you will not be able to access the maps. The expiration details will be accessible for you to examine and/or communicate to the user.

Since
100.5

◆ fileURL

- (NSURL*) fileURL
readnonatomicstrong

The URL of the mobile map package (.mmpk file) on disk or a directory containing an unpacked mobile map package.

Since
100

◆ item

- (AGSItem*) item
readnonatomicstrong

The mobile map package's AGSItem object describing metadata about the package.

The item includes the metadata about the mobile map package, such as:

  • Title
  • Snippet (summary)
  • Description
  • Tags
  • Thumbnail If the package was created with ArcGIS Pro, the metadata was provided by the package author. If the package was created using the AGSOfflineMapTask, the metadata was provided by the originating web map.

A package's item will be an instance of an AGSLocalItem.

Returns nil if the package is not loaded.

See also
AGSItem
Since
100

◆ loadError

- (NSError*) loadError
readnonatomicstronginherited

The error that was encountered during the most recent load operation. Will be nil if the operation succeeded.

Since
100

◆ loadStatus

- (AGSLoadStatus) loadStatus
readrequirednonatomicassigninherited

Status of the load operation.

Since
100

◆ locatorTask

- (AGSLocatorTask*) locatorTask
readnonatomicstrong

An AGSLocatorTask object from the mobile map package.

Use this task to geocode and reverse-geocode addresses and places. There is only one AGSLocatorTask object in each mobile map package but it can be used by all maps.

Returns nil if there is no AGSLocatorTask in the package or the package is not loaded.

See also
AGSLocatorTask
Since
100

◆ maps

- (NSArray<AGSMap*>*) maps
readnonatomiccopy

An array of AGSMap objects from the AGSMobileMapPackage object.

To use the maps in an AGSMobileMapPackage object, you first need to load the package. If the mobile map package was created with ArcGIS Pro, the maps are presented in the same order in which they were packaged. Mobile map packages created with the AGSOfflineMapTask object will only contain one map.

If you display the map by setting the map to an AGSMapView object, the map will automatically load. If you only need to access the map's content or metadata, you will need to load it by calling AGSMap::load. If the package is not loaded, an empty NSArray is returned.

Since
100

◆ version

- (NSString*) version
readnonatomiccopy

The mobile map package's version.

The mobile map package version is set when the package is authored in ArcGIS Pro or when it is generated by the AGSOfflineMapTask object.

This property will be populated when you attempt to load the package. The version property will always be populated for you to examine, even if the package is an unsupported version.

ArcGIS Runtime SDKs currently support mobile map packages up to and including major version 5.

You may wish to check the version property before trying to access specific functionality.

For example:

  • Expiration details are only available from mobile map package version 3.1 onwards
  • Links to online services are only available from mobile map package version 4.0 onwards

If the package fails to load, check that the version number has not exceeded the supported major version.

Since
100