diff options
author | Jason Wray <jason@mapbox.com> | 2017-06-13 22:37:56 -0400 |
---|---|---|
committer | Jason Wray <jason@mapbox.com> | 2017-09-06 17:11:09 -0400 |
commit | cb7eb5cafb18ed24d01a9d091b68ed4f0584966b (patch) | |
tree | 5ad3f61af77e6fee2e4fbfe3f18d04fd93e2d253 /platform/ios/app/MBXViewController.m | |
parent | 87348234d16915176fab313f0d3f2dae246216d9 (diff) | |
download | qtlocation-mapboxgl-cb7eb5cafb18ed24d01a9d091b68ed4f0584966b.tar.gz |
[ios] Improve iosapp's zoom debug label
Diffstat (limited to 'platform/ios/app/MBXViewController.m')
-rw-r--r-- | platform/ios/app/MBXViewController.m | 36 |
1 files changed, 25 insertions, 11 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 |