在特定视图中显示 google 个地图

Display google map in particular view

我希望 google 地图只显示在屏幕的一半,还有其他项目要显示在屏幕的另一半。所以,我将 iPhone 屏幕分成两个 UIView,mapViewdetailView。当我尝试在 mapView 中放置 google 地图时,它会显示空白屏幕。而当分配给 self.view 时,它会在整个屏幕上显示地图,如下所示。

不显示在 mapView 中

GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86
                                                        longitude:151.20
                                                             zoom:6];
GMSMapView *mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
mapView_.myLocationEnabled = YES;
self.mapView = mapView_; //Doesn't work

// Creates a marker in the center of the map.
GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake(-33.86, 151.20);
marker.title = @"Sydney";
marker.snippet = @"Australia";
marker.map = mapView_;

更改此行:

GMSMapView *mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];

为此:

   GMSMapView *mapView_ = [GMSMapView mapWithFrame:self.mapView.frame camera:camera];

如果您适当地设置了单独的视图并且应该与该视图框架相匹配,那应该可以解决您的问题。