diff options
Diffstat (limited to 'platform/ios/app')
-rw-r--r-- | platform/ios/app/MBXOrnamentsViewController.h | 5 | ||||
-rw-r--r-- | platform/ios/app/MBXOrnamentsViewController.m | 93 | ||||
-rw-r--r-- | platform/ios/app/MBXViewController.m | 11 |
3 files changed, 108 insertions, 1 deletions
diff --git a/platform/ios/app/MBXOrnamentsViewController.h b/platform/ios/app/MBXOrnamentsViewController.h new file mode 100644 index 0000000000..087101cdc0 --- /dev/null +++ b/platform/ios/app/MBXOrnamentsViewController.h @@ -0,0 +1,5 @@ +#import <UIKit/UIKit.h> + +@interface MBXOrnamentsViewController : UIViewController + +@end diff --git a/platform/ios/app/MBXOrnamentsViewController.m b/platform/ios/app/MBXOrnamentsViewController.m new file mode 100644 index 0000000000..5e575f8c7d --- /dev/null +++ b/platform/ios/app/MBXOrnamentsViewController.m @@ -0,0 +1,93 @@ +#import "MBXOrnamentsViewController.h" + +@import Mapbox; + +@interface MBXOrnamentsViewController ()<MGLMapViewDelegate> + +@property (nonatomic) MGLMapView *mapView; +@property (nonatomic) NSTimer *timer; +@property (nonatomic) NSInteger currentPositionIndex; + +@end + +@implementation MBXOrnamentsViewController + +- (void)setCurrentPositionIndex:(NSInteger)currentPositionIndex { + NSArray *ornamentPositions = @[@[ + @(MGLOrnamentPositionTopLeft), + @(MGLOrnamentPositionTopRight), + @(MGLOrnamentPositionBottomRight), + @(MGLOrnamentPositionBottomLeft) + ], + @[ + @(MGLOrnamentPositionTopRight), + @(MGLOrnamentPositionBottomRight), + @(MGLOrnamentPositionBottomLeft), + @(MGLOrnamentPositionTopLeft) + ], + @[ + @(MGLOrnamentPositionBottomRight), + @(MGLOrnamentPositionBottomLeft), + @(MGLOrnamentPositionTopLeft), + @(MGLOrnamentPositionTopRight) + ], + @[ + @(MGLOrnamentPositionBottomLeft), + @(MGLOrnamentPositionTopLeft), + @(MGLOrnamentPositionTopRight), + @(MGLOrnamentPositionBottomRight) + ], + @[ + @(MGLOrnamentPositionTopLeft), + @(MGLOrnamentPositionTopRight), + @(MGLOrnamentPositionBottomRight), + @(MGLOrnamentPositionBottomLeft) + ], + ]; + NSArray *currentPosition = ornamentPositions[currentPositionIndex]; + self.mapView.scaleBarPosition = [currentPosition[0] integerValue]; + self.mapView.compassViewPosition = [currentPosition[1] integerValue]; + self.mapView.logoViewPosition = [currentPosition[2] integerValue]; + self.mapView.attributionButtonPosition = [currentPosition[3] integerValue]; + + _currentPositionIndex = currentPositionIndex; +} + +- (void)viewDidLoad { + [super viewDidLoad]; + self.title = @"Ornaments"; + + MGLMapView *mapView = [[MGLMapView alloc] initWithFrame:self.view.frame]; + mapView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; + [mapView setCenterCoordinate:CLLocationCoordinate2DMake(39.915143, 116.404053) + zoomLevel:16 + direction:30 + animated:NO]; + mapView.delegate = self; + mapView.showsScale = YES; + [self.view addSubview:mapView]; + + self.mapView = mapView; +} + +- (void)viewDidDisappear:(BOOL)animated { + [self.timer invalidate]; + self.timer = nil; +} + +- (void)viewDidAppear:(BOOL)animated { + self.timer = [NSTimer scheduledTimerWithTimeInterval:1 + target:self + selector:@selector(onTimerTick) + userInfo:nil + repeats:YES]; +} + +- (void)onTimerTick { + self.currentPositionIndex ++; + if (self.currentPositionIndex >= 4) { + self.currentPositionIndex = 0; + } +} + +@end diff --git a/platform/ios/app/MBXViewController.m b/platform/ios/app/MBXViewController.m index b2c6ca26b3..9c506cadfa 100644 --- a/platform/ios/app/MBXViewController.m +++ b/platform/ios/app/MBXViewController.m @@ -7,6 +7,7 @@ #import "MBXUserLocationAnnotationView.h" #import "LimeGreenStyleLayer.h" #import "MBXEmbeddedMapViewController.h" +#import "MBXOrnamentsViewController.h" #import "MBXFrameTimeGraphView.h" @@ -104,8 +105,9 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { MBXSettingsMiscellaneousShowSnapshots, MBXSettingsMiscellaneousShouldLimitCameraChanges, MBXSettingsMiscellaneousShowCustomLocationManager, + MBXSettingsMiscellaneousOrnamentsPlacement, MBXSettingsMiscellaneousPrintLogFile, - MBXSettingsMiscellaneousDeleteLogFile, + MBXSettingsMiscellaneousDeleteLogFile }; // Utility methods @@ -499,6 +501,7 @@ CLLocationCoordinate2D randomWorldCoordinate() { @"Show Snapshots", [NSString stringWithFormat:@"%@ Camera Changes", (_shouldLimitCameraChanges ? @"Unlimit" : @"Limit")], @"View Route Simulation", + @"Ornaments Placement", ]]; if (self.debugLoggingEnabled) @@ -756,6 +759,12 @@ CLLocationCoordinate2D randomWorldCoordinate() { } break; } + case MBXSettingsMiscellaneousOrnamentsPlacement: + { + MBXOrnamentsViewController *ornamentsViewController = [[MBXOrnamentsViewController alloc] init]; + [self.navigationController pushViewController:ornamentsViewController animated:YES]; + break; + } default: NSAssert(NO, @"All miscellaneous setting rows should be implemented"); break; |