diff options
Diffstat (limited to 'platform/darwin/src/MGLMapSnapshotter.h')
-rw-r--r-- | platform/darwin/src/MGLMapSnapshotter.h | 62 |
1 files changed, 40 insertions, 22 deletions
diff --git a/platform/darwin/src/MGLMapSnapshotter.h b/platform/darwin/src/MGLMapSnapshotter.h index 8bc929e3a9..b6228269cf 100644 --- a/platform/darwin/src/MGLMapSnapshotter.h +++ b/platform/darwin/src/MGLMapSnapshotter.h @@ -69,23 +69,42 @@ MGL_EXPORT @end +/** + An image generated by a snapshotter object. + */ +@interface MGLMapSnapshot : NSObject + #if TARGET_OS_IPHONE /** - A block to processes the result or error of a snapshot request. - - @param snapshot The `UIImage` that was generated or `nil` if an error occurred. - @param error The error that occured or `nil` when successful. + Converts the specified map coordinate to a point in the coordinate space of the image. */ -typedef void (^MGLMapSnapshotCompletionHandler)(UIImage* _Nullable snapshot, NSError* _Nullable error); +- (CGPoint)pointForCoordinate:(CLLocationCoordinate2D)coordinate; + +/** + The image of the map’s content. + */ +@property(nonatomic, readonly) UIImage *image; #else /** + Converts the specified map coordinate to a point in the coordinate space of the image. + */ +- (NSPoint)pointForCoordinate:(CLLocationCoordinate2D)coordinate; + +/** + The image of the map’s content. + */ +@property(nonatomic, readonly) NSImage *image; +#endif + +@end + +/** A block to processes the result or error of a snapshot request. - @param snapshot The `NSImage` that was generated or `nil` if an error occurred. - @param error The eror that occured or `nil` when succesful. + @param snapshot The `MGLMapSnapshot` that was generated or `nil` if an error occurred. + @param error The error that occured or `nil` when successful. */ -typedef void (^MGLMapSnapshotCompletionHandler)(NSImage* _Nullable snapshot, NSError* _Nullable error); -#endif +typedef void (^MGLMapSnapshotCompletionHandler)(MGLMapSnapshot* _Nullable snapshot, NSError* _Nullable error); /** An immutable utility object for capturing map-based images. @@ -93,20 +112,18 @@ typedef void (^MGLMapSnapshotCompletionHandler)(NSImage* _Nullable snapshot, NSE ### Example ```swift - var camera = MGLMapCamera() - camera.centerCoordinate = CLLocationCoordinate2D(latitude: 37.7184, longitude: -122.4365) - camera.pitch = 20 + let camera = MGLMapCamera(lookingAtCenter: CLLocationCoordinate2D(latitude: 37.7184, longitude: -122.4365), fromDistance: 100, pitch: 20, heading: 0) - var options = MGLMapSnapshotOptions(styleURL: MGLStyle.satelliteStreetsStyleURL(), camera: camera, size: CGSize(width: 320, height: 480)) + let 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 - } + let snapshotter = MGLMapSnapshotter(options: options) + snapshotter.start { (snapshot, error) in + if error != nil { + // error handler + } else { + // image handler + } } ``` */ @@ -141,7 +158,8 @@ MGL_EXPORT /** The zoom level. - The default zoom level is 0. This overwrites the camera zoom level if set. + The default zoom level is 0. If this property is non-zero and the camera property + is non-nil, the camera’s altitude is ignored in favor of this property’s value. */ @property (nonatomic) double zoomLevel; @@ -169,7 +187,7 @@ MGL_EXPORT map ID (`mapbox://styles/{user}/{style`}), or a path to a local file relative to the application’s resource path. Specify `nil` for the default style. */ -@property (nonatomic) NSURL* styleURL; +@property (nonatomic, nullable) NSURL *styleURL; /** The size of the output image, measured in points. |