我尝试使用 GoogleMapsSDKDemos 中的代码将地图视图调整为屏幕上较小的矩形,但它似乎没有任何效果。这是我的代码:
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 限制为一个小方块,但它仍然占据了整个屏幕。