我尝试使用GoogleMapsSDKDemos中的代码将mapview的大小调整为屏幕上的一个较小的矩形,但似乎没有任何效果。这是我的代码:
mapView = [[GMSMapView alloc] initWithFrame:CGRectZero];
mapView.camera = [GMSCameraPosition cameraWithLatitude:38.98549782690282
经度:-76.94636067188021
缩放: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];
倒数第二行似乎应该将MapView限制为一个小正方形,但仍占据整个屏幕。
最佳答案
我会尝试这样的事情:
GMSCameraPosition* camera = [GMSCameraPosition
cameraWithLatitude: 38.98549782690282
longitude: -76.94636067188021
zoom: 17];
GMSMapView* mapView =
[GMSMapView mapWithFrame: GRectMake(0,0, 10, 25) camera: camera];
请注意,对
GMSMapView
中的GMSMapView.h
类的注释说:此类不应直接被实例化,而必须是
使用[GMSMapServices mapWithFrame:camera:]创建
关于ios - 调整Google Maps MapView iOS的大小,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15315271/