diff options
author | jmkiley <jordan.kiley@mapbox.com> | 2017-06-13 15:21:50 -0700 |
---|---|---|
committer | jmkiley <jordan.kiley@mapbox.com> | 2017-06-13 15:21:50 -0700 |
commit | 04a0c64482c045bd622a8d1c4ad6ca1baace2c34 (patch) | |
tree | 9c978aa3e4850f71fa26fb033f2cb3c81c58b555 /platform/ios/demo/Examples/ObjectiveC/CameraAnimationExample.m | |
parent | 17ccd0100ceff3ab7d4dd6eb58e3345745dff117 (diff) | |
download | qtlocation-mapboxgl-upstream/jk-nb-pod-try.tar.gz |
[ios] added demo projectupstream/jk-nb-pod-try
Diffstat (limited to 'platform/ios/demo/Examples/ObjectiveC/CameraAnimationExample.m')
-rw-r--r-- | platform/ios/demo/Examples/ObjectiveC/CameraAnimationExample.m | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/platform/ios/demo/Examples/ObjectiveC/CameraAnimationExample.m b/platform/ios/demo/Examples/ObjectiveC/CameraAnimationExample.m new file mode 100644 index 0000000000..2e32826e0b --- /dev/null +++ b/platform/ios/demo/Examples/ObjectiveC/CameraAnimationExample.m @@ -0,0 +1,40 @@ +#import "CameraAnimationExample.h" +@import Mapbox; + +NSString *const MBXExampleCameraAnimation = @"CameraAnimationExample"; + +@interface CameraAnimationExample () <MGLMapViewDelegate> +@end + +@implementation CameraAnimationExample + +- (void)viewDidLoad { + [super viewDidLoad]; + + MGLMapView *mapView = [[MGLMapView alloc] initWithFrame:self.view.bounds]; + mapView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; + mapView.delegate = self; + + mapView.styleURL = [MGLStyle outdoorsStyleURLWithVersion:9]; + + // Mauna Kea, Hawaii + CLLocationCoordinate2D center = CLLocationCoordinate2DMake(19.820689, -155.468038); + + // Optionally set a starting point. + [mapView setCenterCoordinate:center zoomLevel:7 direction:0 animated:NO]; + + [self.view addSubview:mapView]; +} + +-(void)mapViewDidFinishLoadingMap:(MGLMapView *)mapView { + // Wait for the map to load before initiating the first camera movement. + + // Create a camera that rotates around the same center point, rotating 180°. + // `fromDistance:` is meters above mean sea level that an eye would have to be in order to see what the map view is showing. + MGLMapCamera *camera = [MGLMapCamera cameraLookingAtCenterCoordinate:mapView.centerCoordinate fromDistance:4500 pitch:15 heading:180]; + + // Animate the camera movement over 5 seconds. + [mapView setCamera:camera withDuration:5 animationTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]]; +} + +@end |