如何在我的ViewController中设置Google Maps应用程序的大小? [英] How do I set the size of Google Maps app within my ViewController?

查看:148
本文介绍了如何在我的ViewController中设置Google Maps应用程序的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始了一个全新的单一视图项目,只集成了Google地图SDK。

现在它横跨所有屏幕(全尺寸),我相信这是默认设置。我想减少它,所以它不占用顶部栏上的空间,我也想留下底部的空间来放置按钮。我该怎么做?



以下是我的(单个)视图控制器类中实现的唯一方法:

<$ p $ b $创建一个GMSCameraPosition,它告诉地图在缩放级别6显示
//坐标-33.86,151.20。$ b $ - (void)loadView {
// $ b GMSCameraPosition * camera = [GMSCameraPosition cameraWithLatitude:-33.86
longitude:151.20
zoom:6];
GMSMapView * mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
mapView.myLocationEnabled = YES;
self.view = mapView;

//在地图的中心创建一个标记。
GMSMarker * marker = [[GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake(-33.86,151.20);
marker.title = @悉尼;
marker.snippet = @澳大利亚;
marker.map = mapView;
}


解决方案

  1)在您想要的ViewController中添加一个UIView并设置您的自定义大小
2)将它的类型设置为IdentityInspector中的GMSMapView



delcare IBOutlet in .H file


  @property(弱,非原子)IBOutlet GMSMapView * map1; 

.M

   - (void)viewDidLoad {
[super viewDidLoad];
GMSCameraPosition * camera = [GMSCameraPosition cameraWithLatitude:1.285
longitude:103.848
zoom:12];
self.map1.camera =相机;
self.map1.delegate = self;
self.map1.accessibilityElementsHidden = NO;
self.map1.indoorEnabled = NO;
self.map1.settings.myLocationButton = YES;
dispatch_async(dispatch_get_main_queue(),^ {
self.map1.myLocationEnabled = YES;
});
}

查看此博客 http://vikrambahl.com/google-maps-ios-xcode-storyboards/


I started a brand new Single View project with just Google Maps SDK being integrated in it.

Right now it spans over all the screen (full-size), which I believe is the default setting. I want to reduce it so it doesn't take up space on the top bar and I also want to leave space on the bottom for my buttons. How do I do so?

Here's the only method implemented in my (single) view controller class:

- (void)loadView {
// Create a GMSCameraPosition that tells the map to display the
// coordinate -33.86,151.20 at zoom level 6.
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86
                                                        longitude:151.20
                                                             zoom:6];
GMSMapView *mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
mapView.myLocationEnabled = YES;
self.view = mapView;

// 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;
}

解决方案

1)Add a UIView into the ViewController where you want and set your custom size
2)set it's type to be GMSMapView in IdentityInspector

delcare IBOutlet in .H file

@property (weak, nonatomic) IBOutlet GMSMapView *map1;

.M

- (void)viewDidLoad {
    [super viewDidLoad];
    GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:1.285
                                                                longitude:103.848
                                                                     zoom:12];
        self.map1.camera = camera;
        self.map1.delegate=self;
        self.map1.accessibilityElementsHidden = NO;
        self.map1.indoorEnabled = NO;
        self.map1.settings.myLocationButton = YES; 
        dispatch_async(dispatch_get_main_queue(), ^{
            self.map1.myLocationEnabled = YES;
        });
}

check this blog http://vikrambahl.com/google-maps-ios-xcode-storyboards/

这篇关于如何在我的ViewController中设置Google Maps应用程序的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆