I am loading a Google Place from the autocomplete API then looking up place details to zoom in on my map.
I have a GMSMapView
defined in my XIB which I can see when I run my view controller.
Originally the zoom level is at 4. When I set the coordinate and zoom level, it stays zoomed out despite my debugger saying the zoom level is 2.
How do I zoom in?
(lldb) po self.map
<GMSMapView: 0x7f8c62a9ebc0; frame = (0 73.3333; 414 576.667); clipsToBounds = YES; autoresize = RM+BM; gestureRecognizers = <NSArray: 0x7f8c67029fc0>; layer = <GMSMapLayer: 0x7f8c62a57aa0>>
(lldb) po self.map.camera
GMSCameraPosition 0x7f8c62d2d030: target:(29.741, -95.374) bearing:0.000 zoomLevel:2.000 viewingAngle:0.000
- (void)viewDidLoad {
[super viewDidLoad];
[self setupButtons];
self.map.delegate = self;
self.client = [GMSPlacesClient sharedClient];
[self.client lookUpPlaceID:self.prediction.placeID callback:^(GMSPlace * _Nullable result, NSError * _Nullable error) {
[self showResult:result];
}];
}
- (void)showResult:(GMSPlace *)place {
self.place = place;
GMSCameraPosition *position = [[GMSCameraPosition alloc] initWithTarget:place.coordinate zoom:0.2 bearing:0 viewingAngle:0];
[self.map setCamera:position];
[self.map animateWithCameraUpdate:[GMSCameraUpdate setTarget:place.coordinate zoom: 0.15]];
[self.map moveCamera:[GMSCameraUpdate setTarget:place.coordinate zoom: 0.15]];
}
I guess you are doing something wrong here. You said that
Originally the zoom level is at 4. When I set the coordinate and zoom level, it stays zoomed out despite my debugger saying the zoom level is 2.
Just to be clear, zoom level 4 is > zoom level 2. If you want your map to be zoomed in try using higher values i.e. around 15, 16 etc.
Hope it helps.