Resize Google Maps iOS Maps

I tried using the code from GoogleMapsSDKDemos to resize the mapview to a smaller rectangle on the screen, but it does not seem to have any effect. Here is my code:

mapView = [[GMSMapView alloc] initWithFrame: CGRectZero]; mapView.camera = [Camera GMSCameraPositionWithLatitude: 38.98549782690282 longitude: -76.94636067188021 increase: 17];

self.view = [[UIView alloc] initWithFrame:CGRectZero]; mapView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; mapView.frame = self.view.frame; mapView.clipsToBounds = YES; mapView.myLocationEnabled = YES; mapView.settings.tiltGestures = NO; mapView.settings.zoomGestures = NO; mapView.frame = CGRectMake(0,0, 10, 25); [self.view addSubview:self.mapView]; 

This second line, apparently, should limit MapView to only a small square, but it still occupies the entire screen.

+4
source share
2 answers

I would try something like this:

 GMSCameraPosition* camera = [GMSCameraPosition cameraWithLatitude: 38.98549782690282 longitude: -76.94636067188021 zoom: 17]; GMSMapView* mapView = [GMSMapView mapWithFrame: GRectMake(0,0, 10, 25) camera: camera]; 

Note that the comments in the GMSMapView class in GMSMapView.h say:

This class should not be installed directly; instead, it must be created using [GMSMapServices mapWithFrame: camera:]

+3
source

Try adding a map to the beginning:

 GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:latitude longitude:longitude zoom:10]; mapView_ = [GMSMapView mapWithFrame:CGRectMake(0,0, width, height) camera:camera]; mapView_.delegate = self; mapView_.myLocationEnabled = YES; [self.view addSubview:mapView_]; 
+1
source

All Articles