MGLMapSnapshotter
@interface MGLMapSnapshotter : NSObject
An immutable utility object for capturing map-based images.
Example
var camera = MGLMapCamera()
camera.centerCoordinate = CLLocationCoordinate2D(latitude: 37.7184, longitude: -122.4365)
camera.pitch = 20
var options = MGLMapSnapshotOptions(styleURL: MGLStyle.satelliteStreetsStyleURL(), camera: camera, size: CGSize(width: 320, height: 480))
options.zoomLevel = 10
var snapshotter = MGLMapSnapshotter(options: options)
snapshotter.start { (image, error) in
if error {
// error handler
} else {
// image handler
}
}
-
Starts the snapshot creation and executes the specified block with the result.
Declaration
Objective-C
- (void)startWithCompletionHandler: (nonnull MGLMapSnapshotCompletionHandler)completionHandler;
Swift
func start(completionHandler: @escaping MGLMapSnapshotCompletionHandler)
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 MGLMapSnapshotCompletionHandler)completionHandler;
Swift
func start(with queue: DispatchQueue, completionHandler: @escaping MGLMapSnapshotCompletionHandler)
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
MGLMapSnapshotter
object.Declaration
Objective-C
- (void)cancel;
Swift
func cancel()
-
Indicates whether as snapshot is currently being generated.
Declaration
Objective-C
@property (readonly, getter=isLoading, nonatomic) BOOL loading;
Swift
var isLoading: Bool { get }