From 911fafce52bc76822ba498779f4817566c9ed02d Mon Sep 17 00:00:00 2001 From: jmkiley Date: Wed, 27 Mar 2019 14:08:32 -0700 Subject: test test --- platform/ios/app/MBXTestViewController.h | 17 +++++ platform/ios/app/MBXTestViewController.m | 114 +++++++++++++++++++++++++++++ platform/ios/ios.xcodeproj/project.pbxproj | 20 +++-- 3 files changed, 145 insertions(+), 6 deletions(-) create mode 100644 platform/ios/app/MBXTestViewController.h create mode 100644 platform/ios/app/MBXTestViewController.m diff --git a/platform/ios/app/MBXTestViewController.h b/platform/ios/app/MBXTestViewController.h new file mode 100644 index 0000000000..8950e751ce --- /dev/null +++ b/platform/ios/app/MBXTestViewController.h @@ -0,0 +1,17 @@ +// +// MBXTestViewController.h +// iosapp +// +// Created by Jordan on 3/27/19. +// Copyright © 2019 Mapbox. All rights reserved. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface MBXTestViewController : UIViewController + +@end + +NS_ASSUME_NONNULL_END diff --git a/platform/ios/app/MBXTestViewController.m b/platform/ios/app/MBXTestViewController.m new file mode 100644 index 0000000000..f12da8d369 --- /dev/null +++ b/platform/ios/app/MBXTestViewController.m @@ -0,0 +1,114 @@ +#import + +#import "../src/MGLMapView_Experimental.h" +#import "MBXFrameTimeGraphView.h" +#import "MBXTestViewController.h" + +@interface CustomAnnotationView : MGLAnnotationView +@end + +@implementation CustomAnnotationView + +- (void)layoutSubviews { + [super layoutSubviews]; + + // Use CALayer’s corner radius to turn this view into a circle. + self.layer.cornerRadius = self.bounds.size.width / 2; + self.layer.borderWidth = 2; + self.layer.borderColor = [UIColor whiteColor].CGColor; +} + +- (void)setSelected:(BOOL)selected animated:(BOOL)animated { + [super setSelected:selected animated:animated]; + + // Animate the border width in/out, creating an iris effect. + CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"borderWidth"]; + animation.duration = 0.1; + self.layer.borderWidth = selected ? self.bounds.size.width / 4 : 2; + [self.layer addAnimation:animation forKey:@"borderWidth"]; +} + +@end + + +// +// Example view controller +@interface MBXTestViewController () +@property (nonatomic) MGLMapView *mapView; +@property (nonatomic) NSTimer *timer; +@end + +@implementation MBXTestViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + self.mapView = [[MGLMapView alloc] initWithFrame:self.view.bounds]; + self.mapView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; + self.mapView.styleURL = [MGLStyle darkStyleURL]; + self.mapView.tintColor = [UIColor lightGrayColor]; + self.mapView.centerCoordinate = CLLocationCoordinate2DMake(0, 66); + self.mapView.zoomLevel = 2; + self.mapView.delegate = self; + [self.view addSubview:self.mapView]; + + // Specify coordinates for our annotations. + CLLocationCoordinate2D coordinates[] = { + CLLocationCoordinate2DMake(0, 33), + CLLocationCoordinate2DMake(0, 66), + CLLocationCoordinate2DMake(0, 99), + }; + NSUInteger numberOfCoordinates = sizeof(coordinates) / sizeof(CLLocationCoordinate2D); + + // Fill an array with point annotations and add it to the map. + NSMutableArray *pointAnnotations = [NSMutableArray arrayWithCapacity:numberOfCoordinates]; + for (NSUInteger i = 0; i < numberOfCoordinates; i++) { + CLLocationCoordinate2D coordinate = coordinates[i]; + MGLPointAnnotation *point = [[MGLPointAnnotation alloc] init]; + point.coordinate = coordinate; + point.title = [NSString stringWithFormat:@"%.f, %.f", coordinate.latitude, coordinate.longitude]; + [pointAnnotations addObject:point]; + } + + [self.mapView addAnnotations:pointAnnotations]; + [_timer invalidate]; + _timer = [NSTimer scheduledTimerWithTimeInterval:5 target:self selector:@selector(updateCenter) userInfo:nil repeats:YES]; +} + +- (void)updateCenter { + // CLLocationCoordinate2D coord = CLLocationCoordinate2DMake(arc4random_uniform(180) - 90, arc4random_uniform(360) - 180); + // self.mapView.centerCoordinate = coord; +} +#pragma mark - MGLMapViewDelegate methods + +// This delegate method is where you tell the map to load a view for a specific annotation. To load a static MGLAnnotationImage, you would use `-mapView:imageForAnnotation:`. +- (MGLAnnotationView *)mapView:(MGLMapView *)mapView viewForAnnotation:(id )annotation { + // This example is only concerned with point annotations. + if (![annotation isKindOfClass:[MGLPointAnnotation class]]) { + return nil; + } + + // Use the point annotation’s longitude value (as a string) as the reuse identifier for its view. + NSString *reuseIdentifier = [NSString stringWithFormat:@"%f", annotation.coordinate.longitude]; + + // For better performance, always try to reuse existing annotations. + CustomAnnotationView *annotationView = [mapView dequeueReusableAnnotationViewWithIdentifier:reuseIdentifier]; + + // If there’s no reusable annotation view available, initialize a new one. + if (!annotationView) { + annotationView = [[CustomAnnotationView alloc] initWithReuseIdentifier:reuseIdentifier]; + annotationView.bounds = CGRectMake(0, 0, 40, 40); + + // Set the annotation view’s background color to a value determined by its longitude. + CGFloat hue = (CGFloat)annotation.coordinate.longitude / 100; + annotationView.backgroundColor = [UIColor colorWithHue:hue saturation:0.5 brightness:1 alpha:1]; + } + + return annotationView; +} + +- (BOOL)mapView:(MGLMapView *)mapView annotationCanShowCallout:(id)annotation { + return YES; +} + +@end diff --git a/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/ios.xcodeproj/project.pbxproj index 5122a60b11..330b28377b 100644 --- a/platform/ios/ios.xcodeproj/project.pbxproj +++ b/platform/ios/ios.xcodeproj/project.pbxproj @@ -459,6 +459,7 @@ 96F3F73C1F57124B003E2D2C /* MGLUserLocationHeadingIndicator.h in Headers */ = {isa = PBXBuildFile; fileRef = 96F3F73B1F5711F1003E2D2C /* MGLUserLocationHeadingIndicator.h */; }; 9C188C4F2242C95A0022FA55 /* MMEDate.m in Sources */ = {isa = PBXBuildFile; fileRef = 40834BBC1FE05D6E00C1BD0D /* MMEDate.m */; }; 9C188C502242C96F0022FA55 /* MMEDate.h in Headers */ = {isa = PBXBuildFile; fileRef = 40834BC51FE05D6F00C1BD0D /* MMEDate.h */; }; + A4F36CDD224C1A94001B520C /* MBXTestViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A4F36CDC224C1A94001B520C /* MBXTestViewController.m */; }; AC1B0916221CA14D00DB56C8 /* CLLocationManager+MMEMobileEvents.h in Headers */ = {isa = PBXBuildFile; fileRef = AC1B0914221CA14500DB56C8 /* CLLocationManager+MMEMobileEvents.h */; }; AC1B0917221CA14D00DB56C8 /* CLLocationManager+MMEMobileEvents.h in Headers */ = {isa = PBXBuildFile; fileRef = AC1B0914221CA14500DB56C8 /* CLLocationManager+MMEMobileEvents.h */; }; AC1B0918221CA14D00DB56C8 /* CLLocationManager+MMEMobileEvents.m in Sources */ = {isa = PBXBuildFile; fileRef = AC1B0915221CA14C00DB56C8 /* CLLocationManager+MMEMobileEvents.m */; }; @@ -1143,6 +1144,8 @@ 96ED34DD22374C0900E9FCA9 /* MGLMapViewDirectionTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLMapViewDirectionTests.mm; sourceTree = ""; }; 96F017292118FBAE00892778 /* MGLMapView_Experimental.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLMapView_Experimental.h; sourceTree = ""; }; 96F3F73B1F5711F1003E2D2C /* MGLUserLocationHeadingIndicator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MGLUserLocationHeadingIndicator.h; sourceTree = ""; }; + A4F36CDB224C1A94001B520C /* MBXTestViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MBXTestViewController.h; sourceTree = ""; }; + A4F36CDC224C1A94001B520C /* MBXTestViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MBXTestViewController.m; sourceTree = ""; }; AC1B0914221CA14500DB56C8 /* CLLocationManager+MMEMobileEvents.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "CLLocationManager+MMEMobileEvents.h"; path = "../vendor/mapbox-events-ios/MapboxMobileEvents/CLLocationManager+MMEMobileEvents.h"; sourceTree = ""; }; AC1B0915221CA14C00DB56C8 /* CLLocationManager+MMEMobileEvents.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "CLLocationManager+MMEMobileEvents.m"; path = "../vendor/mapbox-events-ios/MapboxMobileEvents/CLLocationManager+MMEMobileEvents.m"; sourceTree = ""; }; AC518DFD201BB55A00EBC820 /* MGLTelemetryConfig.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MGLTelemetryConfig.h; sourceTree = ""; }; @@ -1967,6 +1970,8 @@ 632281DD1E6F855900D75A5D /* MBXEmbeddedMapViewController.h */, 632281DE1E6F855900D75A5D /* MBXEmbeddedMapViewController.m */, 6FA9341621EF372100AA9CA8 /* MBXOrnamentsViewController.h */, + A4F36CDB224C1A94001B520C /* MBXTestViewController.h */, + A4F36CDC224C1A94001B520C /* MBXTestViewController.m */, 6FA9341521EF372100AA9CA8 /* MBXOrnamentsViewController.m */, DA821D051CCC6D59007508D4 /* Main.storyboard */, DA821D041CCC6D59007508D4 /* LaunchScreen.storyboard */, @@ -2906,6 +2911,7 @@ }; DA1DC9491CB6C1C2006E619F = { CreatedOnToolsVersion = 7.3; + DevelopmentTeam = 85826LGZGV; LastSwiftMigration = 0820; }; DA2E88501CC036F400F24E7B = { @@ -2932,6 +2938,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, Base, "zh-Hans", @@ -3106,6 +3113,7 @@ DA1DC9991CB6E054006E619F /* MBXAppDelegate.m in Sources */, 6FA9341721EF372100AA9CA8 /* MBXOrnamentsViewController.m in Sources */, DA1DC96B1CB6C6B7006E619F /* MBXOfflinePacksTableViewController.m in Sources */, + A4F36CDD224C1A94001B520C /* MBXTestViewController.m in Sources */, DA1DC96A1CB6C6B7006E619F /* MBXCustomCalloutView.m in Sources */, 927FBCFC1F4DAA8300F8BF1F /* MBXSnapshotsViewController.m in Sources */, DA1DC99B1CB6E064006E619F /* MBXViewController.m in Sources */, @@ -3830,10 +3838,10 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - DEVELOPMENT_TEAM = ""; + DEVELOPMENT_TEAM = 85826LGZGV; INFOPLIST_FILE = "$(SRCROOT)/app/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxGL; + PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxGL432; PRODUCT_NAME = "Mapbox GL"; SWIFT_VERSION = 3.0; }; @@ -4159,10 +4167,10 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - DEVELOPMENT_TEAM = ""; + DEVELOPMENT_TEAM = 85826LGZGV; INFOPLIST_FILE = "$(SRCROOT)/app/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxGL; + PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxGL432; PRODUCT_NAME = "Mapbox GL"; SWIFT_VERSION = 3.0; }; @@ -4172,10 +4180,10 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - DEVELOPMENT_TEAM = ""; + DEVELOPMENT_TEAM = 85826LGZGV; INFOPLIST_FILE = "$(SRCROOT)/app/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxGL; + PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxGL432; PRODUCT_NAME = "Mapbox GL"; SWIFT_VERSION = 3.0; }; -- cgit v1.2.1