在uimaps中添加谷歌地图

我用Google地图创build了一个viewcontroller,但是我没有必要在全尺寸的viewcontroller中插入这个卡,我得到了它(新的视图我添加了一个类GMSMapView),但我需要把这个地图标记。 我的标记的例子

CLLocationCoordinate2D position2 = CLLocationCoordinate2DMake(59.957069, 30.323013); GMSMarker *london2 = [GMSMarker markerWithPosition:position2]; london2.title = @"my office"; london2.snippet = @"description"; london2.map = mapView_; 

这是我的代码

 - (void)viewDidLoad { [super viewDidLoad]; self.mapView_.mapType = kGMSTypeNormal; self.mapView_.settings.compassButton = YES; self.mapView_.settings.myLocationButton = YES; self.mapView_.delegate = self; [GMSServices provideAPIKey:@"###"]; GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86 longitude:151.20 zoom:1]; mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera]; mapView_.myLocationEnabled = YES; mapView_.settings.compassButton = YES; mapView_.settings.myLocationButton = YES; //self.view = mapView_; GMSMarker *london2 = [GMSMarker markerWithPosition:position2]; london2.title = @"my office"; london2.snippet = @"description"; london2.map = mapView_; 

问题 – 如果我添加一行self.view = mapView_; 这张卡在整个屏幕上用正确的标记reflection给我,如果我移除它,它会被reflection而没有标记,但是我想要的大小 – 如何修复它(制作所需大小和标记的地图)

你可以改变你的self.view = mapView_;

到以下代码:

 mapView.frame = CGRectMake(YOUR_MAP_X, YOUR_MAP_Y, YOUR_MAP_WIDTH, YOUR_MAP_HEIGHT); [self.view addSubview:mapView_]; 

你的mapView_将是你的主UIView的子视图,而不是占用整个屏幕。