DingiMapSnapshotter


@interface DingiMapSnapshotter : NSObject

An DingiMapSnapshotter generates static raster images of the map. Each snapshot image depicts a portion of a map defined by an DingiMapSnapshotOptions object you provide. The snapshotter generates an DingiMapSnapshot object asynchronously, passing it into a completion handler once tiles and other resources needed for the snapshot are finished loading.

You can change the snapshotter’s options at any time and reuse the snapshotter for multiple distinct snapshots; however, the snapshotter can only generate one snapshot at a time. If you need to generate multiple snapshots concurrently, create multiple snapshotter objects.

For an interactive map, use the DingiMapView class. Both DingiMapSnapshotter and DingiMapView are compatible with offline packs managed by the DingiOfflineStorage class.

Example

let camera = DingiMapCamera(lookingAtCenter: CLLocationCoordinate2D(latitude: 37.7184, longitude: -122.4365), altitude: 100, pitch: 20, heading: 0)

let options = DingiMapSnapshotOptions(styleURL: DingiStyle.satelliteStreetsStyleURL, camera: camera, size: CGSize(width: 320, height: 480))
options.zoomLevel = 10

let snapshotter = DingiMapSnapshotter(options: options)
snapshotter.start { (snapshot, error) in
    if let error = error {
        fatalError(error.localizedDescription)
    }

    image = snapshot?.image
}
  • Initializes and returns a map snapshotter object that produces snapshots according to the given options.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithOptions:
        (nonnull DingiMapSnapshotOptions *)options;

    Swift

    init(options: DingiMapSnapshotOptions)

    Parameters

    options

    The options to use when generating a map snapshot.

    Return Value

    An initialized map snapshotter.

  • Starts the snapshot creation and executes the specified block with the result.

    Declaration

    Objective-C

    - (void)startWithCompletionHandler:
        (nonnull DingiMapSnapshotCompletionHandler)completionHandler;

    Swift

    func start(completionHandler: @escaping DingiMapSnapshotCompletionHandler)

    Parameters

    completionHandler

    The block to handle the result in.

  • Starts the snapshot creation and executes the specified block with the result on the specified queue.

    Declaration

    Objective-C

    - (void)startWithQueue:(nonnull dispatch_queue_t)queue
         completionHandler:
             (nonnull DingiMapSnapshotCompletionHandler)completionHandler;

    Swift

    func start(with queue: DispatchQueue, completionHandler: @escaping DingiMapSnapshotCompletionHandler)

    Parameters

    queue

    The queue to handle the result on.

    completionHandler

    The block to handle the result in.

  • Cancels the snapshot creation request, if any.

    Once you call this method, you cannot resume the snapshot. In order to obtain the snapshot, create a new DingiMapSnapshotter object.

    Declaration

    Objective-C

    - (void)cancel;

    Swift

    func cancel()
  • The options to use when generating a map snapshot.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic)
        DingiMapSnapshotOptions *_Nonnull options;

    Swift

    var options: DingiMapSnapshotOptions { get set }
  • Indicates whether a snapshot is currently being generated.

    Declaration

    Objective-C

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

    Swift

    var isLoading: Bool { get }