summaryrefslogtreecommitdiff
path: root/platform/ios
diff options
context:
space:
mode:
authorFabian Guerra Soto <fabian.guerra@mapbox.com>2017-10-04 10:03:03 -0400
committerGitHub <noreply@github.com>2017-10-04 10:03:03 -0400
commitf01588cac78b5e5411385faa451080a74320500b (patch)
tree1f0540cf5c71475f0ae6714d70b909338fed9b5f /platform/ios
parent6a846ce5a8ff1d62f4eafa3ef5bd0427096ca9e6 (diff)
downloadqtlocation-mapboxgl-f01588cac78b5e5411385faa451080a74320500b.tar.gz
[ios, macos] Improve snap shotter documentation. (#10020)
* [ios, macos] Improve snap shotter documentation. * [macos] Save snapshots in correct format * [macos] Renamed snapshot item to Export Image * [ios, macos] Clarify Snapshotter documentation. * [ios] Fix snapshot scale * [macOS] Fix snapshotter 4x scaling. * [ios] Fix snapshotter final image scale. * [ios, macos] Update snapshotter size documentation. * [ios, macos] Throw an exception when the snapshotter has already started. * [ios, macos] Add snapshotter header example. * [ios, macos] Use one of the predefined Foundation's exception names.
Diffstat (limited to 'platform/ios')
-rw-r--r--platform/ios/app/MBXSnapshotsViewController.m28
-rw-r--r--platform/ios/src/UIImage+MGLAdditions.h2
-rw-r--r--platform/ios/src/UIImage+MGLAdditions.mm4
3 files changed, 17 insertions, 17 deletions
diff --git a/platform/ios/app/MBXSnapshotsViewController.m b/platform/ios/app/MBXSnapshotsViewController.m
index d26479f085..ab5ad97c90 100644
--- a/platform/ios/app/MBXSnapshotsViewController.m
+++ b/platform/ios/app/MBXSnapshotsViewController.m
@@ -18,27 +18,27 @@
@implementation MBXSnapshotsViewController {
// Top row
- MGLMapSnapshotter* snapshotterTL;
- MGLMapSnapshotter* snapshotterTM;
- MGLMapSnapshotter* snapshotterTR;
+ MGLMapSnapshotter* topLeftSnapshotter;
+ MGLMapSnapshotter* topCenterSnapshotter;
+ MGLMapSnapshotter* topRightSnapshotter;
// Bottom row
- MGLMapSnapshotter* snapshotterBL;
- MGLMapSnapshotter* snapshotterBM;
- MGLMapSnapshotter* snapshotterBR;
+ MGLMapSnapshotter* bottomLeftSnapshotter;
+ MGLMapSnapshotter* bottomCenterSnapshotter;
+ MGLMapSnapshotter* bottomRightSnapshotter;
}
- (void)viewDidLoad {
[super viewDidLoad];
// Start snapshotters
- snapshotterTL = [self startSnapshotterForImageView:_snapshotImageViewTL coordinates:CLLocationCoordinate2DMake(37.7184, -122.4365)];
- snapshotterTM = [self startSnapshotterForImageView:_snapshotImageViewTM coordinates:CLLocationCoordinate2DMake(38.8936, -77.0146)];
- snapshotterTR = [self startSnapshotterForImageView:_snapshotImageViewTR coordinates:CLLocationCoordinate2DMake(-13.1356, -74.2442)];
+ topLeftSnapshotter = [self startSnapshotterForImageView:_snapshotImageViewTL coordinates:CLLocationCoordinate2DMake(37.7184, -122.4365)];
+ topCenterSnapshotter = [self startSnapshotterForImageView:_snapshotImageViewTM coordinates:CLLocationCoordinate2DMake(38.8936, -77.0146)];
+ topRightSnapshotter = [self startSnapshotterForImageView:_snapshotImageViewTR coordinates:CLLocationCoordinate2DMake(-13.1356, -74.2442)];
- snapshotterBL = [self startSnapshotterForImageView:_snapshotImageViewBL coordinates:CLLocationCoordinate2DMake(52.5072, 13.4247)];
- snapshotterBM = [self startSnapshotterForImageView:_snapshotImageViewBM coordinates:CLLocationCoordinate2DMake(60.2118, 24.6754)];
- snapshotterBR = [self startSnapshotterForImageView:_snapshotImageViewBR coordinates:CLLocationCoordinate2DMake(31.2780, 121.4286)];
+ bottomLeftSnapshotter = [self startSnapshotterForImageView:_snapshotImageViewBL coordinates:CLLocationCoordinate2DMake(52.5072, 13.4247)];
+ bottomCenterSnapshotter = [self startSnapshotterForImageView:_snapshotImageViewBM coordinates:CLLocationCoordinate2DMake(60.2118, 24.6754)];
+ bottomRightSnapshotter = [self startSnapshotterForImageView:_snapshotImageViewBR coordinates:CLLocationCoordinate2DMake(31.2780, 121.4286)];
}
- (MGLMapSnapshotter*) startSnapshotterForImageView:(UIImageView*) imageView coordinates:(CLLocationCoordinate2D) coordinates {
@@ -46,8 +46,8 @@
MGLMapCamera* mapCamera = [[MGLMapCamera alloc] init];
mapCamera.pitch = 20;
mapCamera.centerCoordinate = coordinates;
- MGLMapSnapshotOptions* options = [[MGLMapSnapshotOptions alloc] initWithStyleURL:[NSURL URLWithString:@"mapbox://styles/mapbox/traffic-day-v2"] camera:mapCamera size:CGSizeMake(imageView.frame.size.width, imageView.frame.size.height)];
- options.zoom = 10;
+ MGLMapSnapshotOptions* options = [[MGLMapSnapshotOptions alloc] initWithStyleURL:[MGLStyle satelliteStreetsStyleURL] camera:mapCamera size:CGSizeMake(imageView.frame.size.width, imageView.frame.size.height)];
+ options.zoomLevel = 10;
// Create and start the snapshotter
MGLMapSnapshotter* snapshotter = [[MGLMapSnapshotter alloc] initWithOptions:options];
diff --git a/platform/ios/src/UIImage+MGLAdditions.h b/platform/ios/src/UIImage+MGLAdditions.h
index 3c179d6324..22bb740242 100644
--- a/platform/ios/src/UIImage+MGLAdditions.h
+++ b/platform/ios/src/UIImage+MGLAdditions.h
@@ -8,7 +8,7 @@ NS_ASSUME_NONNULL_BEGIN
- (nullable instancetype)initWithMGLStyleImage:(const mbgl::style::Image *)styleImage;
-- (nullable instancetype)initWithMGLPremultipliedImage:(const mbgl::PremultipliedImage&&)mbglImage;
+- (nullable instancetype)initWithMGLPremultipliedImage:(const mbgl::PremultipliedImage&&)mbglImage scale:(CGFloat)scale;
- (std::unique_ptr<mbgl::style::Image>)mgl_styleImageWithIdentifier:(NSString *)identifier;
diff --git a/platform/ios/src/UIImage+MGLAdditions.mm b/platform/ios/src/UIImage+MGLAdditions.mm
index 7cf1ed9bcc..8ab1d5c259 100644
--- a/platform/ios/src/UIImage+MGLAdditions.mm
+++ b/platform/ios/src/UIImage+MGLAdditions.mm
@@ -22,14 +22,14 @@
return self;
}
-- (nullable instancetype)initWithMGLPremultipliedImage:(const mbgl::PremultipliedImage&&)mbglImage
+- (nullable instancetype)initWithMGLPremultipliedImage:(const mbgl::PremultipliedImage&&)mbglImage scale:(CGFloat)scale
{
CGImageRef image = CGImageFromMGLPremultipliedImage(mbglImage.clone());
if (!image) {
return nil;
}
- self = [self initWithCGImage:image scale:1.0 orientation:UIImageOrientationUp];
+ self = [self initWithCGImage:image scale:scale orientation:UIImageOrientationUp];
CGImageRelease(image);
return self;