From cb7eb5cafb18ed24d01a9d091b68ed4f0584966b Mon Sep 17 00:00:00 2001 From: Jason Wray Date: Tue, 13 Jun 2017 22:37:56 -0400 Subject: [ios] Improve iosapp's zoom debug label --- platform/ios/app/MBXViewController.m | 36 +++++++++++++++++++++++++----------- platform/ios/app/Main.storyboard | 34 +++++++++++++++++++++------------- 2 files changed, 46 insertions(+), 24 deletions(-) diff --git a/platform/ios/app/MBXViewController.m b/platform/ios/app/MBXViewController.m index 992b7d587a..40e5889526 100644 --- a/platform/ios/app/MBXViewController.m +++ b/platform/ios/app/MBXViewController.m @@ -112,7 +112,7 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { @property (nonatomic) IBOutlet MGLMapView *mapView; -@property (weak, nonatomic) IBOutlet UILabel *hudLabel; +@property (weak, nonatomic) IBOutlet UIButton *hudLabel; @property (nonatomic) NSInteger styleIndex; @property (nonatomic) BOOL debugLoggingEnabled; @property (nonatomic) BOOL customUserLocationAnnnotationEnabled; @@ -161,6 +161,7 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { self.debugLoggingEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:@"MGLMapboxMetricsDebugLoggingEnabled"]; self.mapView.scaleBar.hidden = NO; self.hudLabel.hidden = YES; + self.hudLabel.titleLabel.font = [UIFont monospacedDigitSystemFontOfSize:10 weight:UIFontWeightRegular]; if ([MGLAccountManager accessToken].length) { @@ -350,7 +351,7 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { [settingsTitles addObjectsFromArray:@[ [NSString stringWithFormat:@"%@ Reuse Queue Stats", (_reuseQueueStatsEnabled ? @"Hide" :@"Show")], @"Start World Tour", - [NSString stringWithFormat:@"%@ Zoom Level", (_showZoomLevelEnabled ? @"Hide" :@"Show")], + [NSString stringWithFormat:@"%@ Zoom/Pitch/Direction Label", (_showZoomLevelEnabled ? @"Hide" :@"Show")], @"Embedded Map View", [NSString stringWithFormat:@"%@ Second Map", ([self.view viewWithTag:2] == nil ? @"Show" : @"Hide")], [NSString stringWithFormat:@"Show Labels in %@", (_usingLocaleBasedCountryLabels ? @"Default Language" : [[NSLocale currentLocale] displayNameForKey:NSLocaleIdentifier value:[self bestLanguageForUser]])], @@ -538,6 +539,7 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { self.reuseQueueStatsEnabled = !self.reuseQueueStatsEnabled; self.hudLabel.hidden = !self.reuseQueueStatsEnabled; self.showZoomLevelEnabled = NO; + [self updateHUD]; break; } case MBXSettingsMiscellaneousShowZoomLevel: @@ -545,6 +547,7 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { self.showZoomLevelEnabled = !self.showZoomLevelEnabled; self.hudLabel.hidden = !self.showZoomLevelEnabled; self.reuseQueueStatsEnabled = NO; + [self updateHUD]; break; } case MBXSettingsMiscellaneousScrollView: @@ -1791,22 +1794,33 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { - (void)mapViewRegionIsChanging:(MGLMapView *)mapView { + [self updateHUD]; +} + +- (void)mapView:(MGLMapView *)mapView regionDidChangeAnimated:(BOOL)animated { + [self updateHUD]; +} + +- (void)mapView:(MGLMapView *)mapView didUpdateUserLocation:(MGLUserLocation *)userLocation { + [self updateHUD]; +} + +- (void)updateHUD { + if (!self.reuseQueueStatsEnabled && !self.showZoomLevelEnabled) return; + + NSString *hudString; + if (self.reuseQueueStatsEnabled) { NSUInteger queuedAnnotations = 0; - for (NSArray *queue in self.mapView.annotationViewReuseQueueByIdentifier.allValues) - { + for (NSArray *queue in self.mapView.annotationViewReuseQueueByIdentifier.allValues) { queuedAnnotations += queue.count; } - self.hudLabel.text = [NSString stringWithFormat:@" Visible: %ld Queued: %ld", (unsigned long)mapView.visibleAnnotations.count, (unsigned long)queuedAnnotations]; + hudString = [NSString stringWithFormat:@"Visible: %ld Queued: %ld", (unsigned long)self.mapView.visibleAnnotations.count, (unsigned long)queuedAnnotations]; } else if (self.showZoomLevelEnabled) { - self.hudLabel.text = [NSString stringWithFormat:@" Zoom: %.2f", self.mapView.zoomLevel]; + hudString = [NSString stringWithFormat:@"%.2f ∕ ↕\U0000FE0E%.f° ∕ %.f°", self.mapView.zoomLevel, self.mapView.camera.pitch, self.mapView.direction]; } -} -- (void)mapView:(MGLMapView *)mapView regionDidChangeAnimated:(BOOL)animated { - if (self.showZoomLevelEnabled) { - self.hudLabel.text = [NSString stringWithFormat:@" Zoom: %.2f", self.mapView.zoomLevel]; - } + [self.hudLabel setTitle:hudString forState:UIControlStateNormal]; } @end diff --git a/platform/ios/app/Main.storyboard b/platform/ios/app/Main.storyboard index 40198146ab..4bbefd7d22 100644 --- a/platform/ios/app/Main.storyboard +++ b/platform/ios/app/Main.storyboard @@ -1,11 +1,11 @@ - + - + @@ -33,17 +33,24 @@ -