You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
Instantiating a map view in viewDidLoad and then trying to set a new camera on that map view no longer works in v3.1.0. Moving the camera setting code to viewDidAppear is enough of a delay to make it work.
MapKit allows viewDidLoad camera manipulation.
The pre-v3.1.0 camera animation example which no longer works:
#import"ViewController.h"
#import<Mapbox/Mapbox.h>@interfaceViewController ()
@property (nonatomic) MGLMapView *mapView;
@end@implementationViewController
- (void)viewDidLoad {
[superviewDidLoad];
self.mapView = [[MGLMapView alloc] initWithFrame:self.view.bounds];
self.mapView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
CLLocationCoordinate2D center = CLLocationCoordinate2DMake(50.999, 3.3253);
// Optionally set a starting point, rotated 180°
[self.mapView setCenterCoordinate:center zoomLevel:5direction:180animated:NO];
[self.view addSubview:self.mapView];
// Create a camera that rotates around the same center point, back to 0°// `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:center fromDistance:9000pitch:45heading:0];
// Animate the camera movement over 5 seconds
[self.mapView setCamera:camera withDuration:5animationTimingFunction:[CAMediaTimingFunctionfunctionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
}
@end
I suspect this is a result of #3362. The conversion between altitude and zoom level relies on a vertical field of view that’s measured relative to the view’s height. I suspect the map view and its superview haven’t reached their full height inside of -viewDidLoad.
Instantiating a map view in
viewDidLoad
and then trying to set a new camera on that map view no longer works in v3.1.0. Moving the camera setting code toviewDidAppear
is enough of a delay to make it work.MapKit allows
viewDidLoad
camera manipulation.The pre-v3.1.0 camera animation example which no longer works:
/cc @1ec5
The text was updated successfully, but these errors were encountered: