谷歌地图iOS [英] Google Maps iOS
本文介绍了谷歌地图iOS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在iOS中的 CGRect
中插入Google地图。但是下面的代码仍然在整个iPhone页面中显示地图。我如何解决这个问题
I am trying to insert Google Maps in a CGRect
in iOS. But the code below still displays the map in the entire iPhone page. How do I fix this
CGRect rect = CGRectMake(50, 10, 200, 200);
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.8683
longitude:151.2086
zoom:6];
mapView_ = [GMSMapView mapWithFrame:rect camera:camera];
mapView_.myLocationEnabled = YES;
self.view = mapView_;
GMSMarkerOptions *options = [[GMSMarkerOptions alloc] init];
options.position = CLLocationCoordinate2DMake(-33.8683, 151.2086);
options.title = @"Sydney";
options.snippet = @"Australia";
[mapView_ addMarkerWithOptions:options];
推荐答案
默认情况下,视图控制器的根视图会调整大小填充屏幕。
By default the root view of a view controller is resized to fill the screen.
您需要添加一个单独的视图作为根视图,然后将地图视图添加到其中。例如:
You would need to add a separate view to be the root view, and then add the map view to it. For example:
self.view = [[UIView alloc] initWithFrame: CGRectZero];
[self.view addSubview: mapView_];
这篇关于谷歌地图iOS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文