From 619130afaf96a469cd0442bbed71f18f615fa61c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Thu, 2 Jul 2015 13:25:18 -0700 Subject: [PATCH] Turned the compass into a button Touching down on the compass but dragging outside it should cause the map to pan, not reset to north. Also renamed the property to reflect its new type. This change obsoletes part of 90af18e708b617591766950413e3691449cad2ce but leaves out the accessibility-related changes there. --- include/mbgl/ios/MGLMapView.h | 4 ++-- platform/ios/MGLMapView.mm | 39 +++++++++++++++++++---------------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/include/mbgl/ios/MGLMapView.h b/include/mbgl/ios/MGLMapView.h index d0704a41c6a..f847c0d5468 100644 --- a/include/mbgl/ios/MGLMapView.h +++ b/include/mbgl/ios/MGLMapView.h @@ -73,8 +73,8 @@ IB_DESIGNABLE * The default value of this property is `YES`. */ @property(nonatomic, getter=isRotateEnabled) BOOL rotateEnabled; -/** The compass image view shown in the upper-right when the map is rotated. */ -@property (nonatomic, readonly) UIImageView *compassView; +/** The compass button shown in the upper-right when the map is rotated. */ +@property (nonatomic, readonly) UIButton *compassButton; /** The Mapbox logo image view shown in the lower-left of the map. */ @property (nonatomic, readonly) UIImageView *logoView; diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm index 06a2ef36be8..3e59117600b 100644 --- a/platform/ios/MGLMapView.mm +++ b/platform/ios/MGLMapView.mm @@ -69,7 +69,7 @@ @interface MGLMapView () = 360) degrees -= 360; while (degrees < 0) degrees += 360; - self.compassView.transform = CGAffineTransformMakeRotation(MGLRadiansFromDegrees(degrees)); + self.compassButton.transform = CGAffineTransformMakeRotation(MGLRadiansFromDegrees(degrees)); - if (_mbglMap->getBearing() && self.compassView.alpha < 1) + if (_mbglMap->getBearing() && self.compassButton.alpha < 1) { [UIView animateWithDuration:MGLAnimationDuration delay:0 options:UIViewAnimationOptionBeginFromCurrentState animations:^ { - self.compassView.alpha = 1; + self.compassButton.alpha = 1; } completion:nil]; } - else if (_mbglMap->getBearing() == 0 && self.compassView.alpha > 0) + else if (_mbglMap->getBearing() == 0 && self.compassButton.alpha > 0) { [UIView animateWithDuration:MGLAnimationDuration delay:0 options:UIViewAnimationOptionBeginFromCurrentState animations:^ { - self.compassView.alpha = 0; + self.compassButton.alpha = 0; } completion:nil]; }