Adding a subview like UISlider or UIButtom in Google Maps in iPhone

喜欢而已 提交于 2019-12-05 11:28:37
Raul Claus

Do normal UI building on your current view, then add the GMSMapView as subview (at index 0) of the self.view (DON'T do self.view = mapView;)

Here is the significant code:

mapView = [GMSMapView mapWithFrame:self.view.bounds camera:camera];
[self.view insertSubview:mapView atIndex:0];

Inserting the map view at index 0 will set the rest of the objects in front.

i suggest creating your button programmatically not using storyBoard, i tested this on "Google Maps SDK version: 1.4.0.4450" and it worked.

UIButton *button    = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.frame        = CGRectMake(10, 10, 100, 40);
[button setTitle:@"title" forState:UIControlStateNormal];

GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:40.279526
                                                        longitude:-96.987305
                                                             zoom:2];

self.mapView    = [GMSMapView mapWithFrame:CGRectZero camera:camera];;
self.view       = self.mapView;

[self.view addSubview:button];
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!