我试图使用GoogleMapsSDKDemos中的代码将mapview的大小调整为屏幕上的较小矩形,但它似乎没有任何效果。这里是我的代码:调整Google Maps MapView iOS
mapView = [[GMSMapView alloc] initWithFrame:CGRectZero]; mapView.camera = [GMSCameraPosition cameraWithLatitude:38.98549782690282 longitude:-76.94636067188021 zoom: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限制为一个小方块,但它仍占用整个屏幕。
我只是试过这个,它没有工作,显然我的GMSServices.h文件没有它的mapWithFrame方法。我回去检查API,如果你看[这里](https://developers.google.com/maps/documentation/ios/map#add_a_map)它似乎使用GMMapView类?我不太确定,你说的话会有道理,但xcode无法在GMSServices中找到mapWithFrame方法(我也不能) – CSStudent 2013-03-15 18:25:15
啊,是的,对不起,我是从标题中的评论开始,而不是从我自己的码。你需要在'GMSMapView'上调用'mapWithFrame',而不是'GMSServices'(我猜这个头部的注释是不正确的)。我已经更新了我的代码。 – 2013-03-15 23:23:12
这对我来说似乎还不起作用,你自己试过了吗?我有'smallMap = [GMSMapView mapWithFrame:CGRectMake(0,0,10,25)camera:camera];'smallmap是一个故事板中的GMMapView,它仍占据整个屏幕。 – CSStudent 2013-03-16 03:16:05