iOS Developer Library — Pre-Release

Developer

MKMapSnapshotter Class Reference

Options
Deployment Target:

On This Page
Language:

MKMapSnapshotter

An MKMapSnapshotter object captures map-based imagery asynchronously. Use instances of this class in situations where you want to capture the iOS-provided map content, including the map tiles and imagery. The snapshotter object always captures the best image possible, loading all of the available map tiles before capturing the image. More...

Inheritance


Conforms To


Import Statement


Swift

import MapKit

Objective-C

@import MapKit;

Availability


Available in iOS 7.0 and later.
  • init(options:) - initWithOptions: Designated Initializer

    Initializes and returns a snapshotter object based on the specified options.

    Declaration

    Swift

    init!(options options: MKMapSnapshotOptions!)

    Objective-C

    - (instancetype)initWithOptions:(MKMapSnapshotOptions *)options

    Parameters

    options

    The options to use when capturing the map imagery. If you specify nil for this property, the snapshotter uses a set of default options that capture an image of the current user’s country.

    Return Value

    An initialized snapshotter option.

    Import Statement

    Swift

    import MapKit

    Availability

    Available in iOS 7.0 and later.

  • Submits the request to create a snapshot and delivers the results to the specified block.

    Declaration

    Swift

    func startWithCompletionHandler(_ completionHandler: MKMapSnapshotCompletionHandler!)

    Objective-C

    - (void)startWithCompletionHandler:(MKMapSnapshotCompletionHandler)completionHandler

    Parameters

    completionHandler

    The block to call with the resulting snapshot. This block is executed on the app’s main thread and must not be nil.

    Discussion

    Call this method to begin generating a snapshot image based on the specified parameters. This method executes the request asynchronously.

    The snapshotter delivers the final image to your app only when it is running in the foreground. The snapshotter must render the final image while your app is in the foreground. If you start generating a snapshot while the app is in the background, or if your app moves to the background while a snapshot is in progress, this behavior delays the delivery of the snapshot until your app returns to the foreground.

    In OS X, this method creates both standard and high-resolution representations of the map data and includes both in the returned image object. In iOS, you must specify the image scale you want using the snapshot options, which default to the scale on the current device.

    Import Statement

    Swift

    import MapKit

    Availability

    Available in iOS 7.0 and later.

  • Submits the request to create a snapshot and executes the resulting block on the specified queue.

    Declaration

    Swift

    func startWithQueue(_ queue: dispatch_queue_t!, completionHandler completionHandler: MKMapSnapshotCompletionHandler!)

    Objective-C

    - (void)startWithQueue:(dispatch_queue_t)queue completionHandler:(MKMapSnapshotCompletionHandler)completionHandler

    Parameters

    queue

    The dispatch queue on which to execute the block specified by the completionHandler parameter.

    completionHandler

    The block to call with the resulting snapshot. This block must not be nil.

    Discussion

    Call this method to begin generating a snapshot image based on the specified parameters. This method executes the request asynchronously. When rendering is complete, the snapshotter delivers the results to your block on the dispatch queue in the queue parameter.

    The snapshotter delivers the final image to your app only when it is running in the foreground. The snapshotter must render the final image while your app is in the foreground. If you start generating a snapshot while the app is in the background, or if your app moves to the background while a snapshot is in progress, this behavior delays the delivery of the snapshot until your app returns to the foreground.

    In OS X, this method creates both standard and high-resolution representations of the map data and includes both in the returned image object. In iOS, you must specify the image scale you want using the snapshot options, which default to the scale on the current device.

    Import Statement

    Swift

    import MapKit

    Availability

    Available in iOS 7.0 and later.

  • Cancels the current request to create a snapshot.

    Declaration

    Swift

    func cancel()

    Objective-C

    - (void)cancel

    Discussion

    If the snapshotter is not in the process of generating the snapshot, calling this method does nothing.

    Import Statement

    Swift

    import MapKit

    Availability

    Available in iOS 7.0 and later.

  • loading loading Property

    A Boolean indicating whether the snapshotter is currently generating an image. (read-only)

    Declaration

    Swift

    var loading: Bool { get }

    Objective-C

    @property(nonatomic, readonly, getter=isLoading) BOOL loading

    Import Statement

    Swift

    import MapKit

    Availability

    Available in iOS 7.0 and later.

Data Types

  • A block that processes the results of a snapshot request.

    Declaration

    Swift

    typealias MKMapSnapshotCompletionHandler = (MKMapSnapshot!, NSError!) -> Void

    Objective-C

    typedef void (^MKMapSnapshotCompletionHandler)(MKMapSnapshot *snapshot, NSError *error);

    Discussion

    This block takes the following parameters:

    snapshot

    The image data that was generated or nil if an error occurred

    error

    The error that occurred or nil if the snapshot was generated successfully.

    Import Statement

    Swift

    import MapKit

    Availability

    Available in iOS 7.0 and later.