本文介绍了如何设置mapview的框架 - 在谷歌GMSMap for iOS6的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Google地图视图中为iOS6加载地点。
如何设置地图的框架?
目前是全屏

I am trying to load places inside Google Map View for iOS6.How to set the frame for the Map ?Currently it is fullscreen

 -(void)loadView {

   GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:10.00989
                                                        longitude:76.316142
                                                             zoom:15];
   mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
   self.view = mapView_;

   }

我试过在里面创建一个新的(小)视图当前视图并在其中添加地图,但此时页面未加载。它显示全黑屏幕

I tried by creating a new (small) view inside the current view and add map inside that,but at that time the page is not getting loaded.It shows a full black screen

 -(void)loadView {

  GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:10.00989
                                                        longitude:76.316142
                                                             zoom:15];
   mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];

   [self.view Addsubview:newView];
   self.newView = mapView_;

  // I also tried like this - [self.newView Addsubview:mapView_;

   }


推荐答案

你可以试试......对我有用的东西:)

You can try... what is working for me :)

//header file
...
@property (nonatomic, weak) IBOutlet GMSMapView *mapView;
@property (weak, nonatomic) IBOutlet UIView *subview; //viewForMap
...

实施文件

GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:10.8683
                                                            longitude:76.2086 zoom:6
                                                              bearing:0
                                                         viewingAngle:0
                                                                ];
    self.mapView = [GMSMapView mapWithFrame:_subview.bounds camera:camera];
  [_subview addSubview:_mapView];

这篇关于如何设置mapview的框架 - 在谷歌GMSMap for iOS6的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 04:38