ios - 如何将 Google MapView 放入 UIView 中?

标签 ios uiview google-maps-sdk-ios

我试图将 Google MapView 放入 UIView 但我没有显示任何内容。

我的代码,

*.h

#import <UIKit/UIKit.h>
#import <GoogleMaps/GoogleMaps.h>

@interface ViewController : UIViewController

@property (weak, nonatomic) IBOutlet UIBarButtonItem *btnLocate;
@property (weak, nonatomic) IBOutlet GMSMapView *mapView_;
@property (weak, nonatomic) IBOutlet UIView *mapView;

@end

*.m

GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86
                                                            longitude:151.20
                                                                 zoom:6];
    self.mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
    self.mapView_.myLocationEnabled = YES;
    self.mapView = self.mapView_;

谢谢。

解决方案

GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86
                                                            longitude:151.20
                                                                 zoom:6];

    // Indicating the map frame bounds
    self.mapView_ = [GMSMapView mapWithFrame:self.mapView.bounds camera: camera]; 
    self.mapView_.myLocationEnabled = YES;

    // Add as subview the mapview
    [self.mapView addSubview: self.mapView_]; 

所以,我得到了解决方案。无论如何谢谢。

最好的问候。

最佳答案

解决方法:

GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86
                                                            longitude:151.20
                                                                 zoom:6];

    // Indicating the map frame bounds
    self.mapView_ = [GMSMapView mapWithFrame:self.mapView.bounds camera: camera]; 
    self.mapView_.myLocationEnabled = YES;

    // Add as subview the mapview
    [self.mapView addSubview: self.mapView_]; 

关于ios - 如何将 Google MapView 放入 UIView 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19177897/

相关文章:

ios - Google Maps iOS SDK 中的位置点显示为正方形

ios - 谷歌地图自定义夜间模式 iOS

ios - 带有圆角和白色边框的UIView有轮廓,如何去掉轮廓

ios - 我将部署目标设置为 iOS8 ,应用商店显示 "Compatibility: Requires iOS 7.0 or later"。我可以强制应用程序仅安装在 iOS8 中吗?

ios - 如何在 iOS 中添加相对于其他 UI 元素的 UILabel

google-maps-markers - 如何强制刷新Google Maps iOS SDK中markerInfoWindow的内容

ios - Twitter 列入白名单的 ios 应用程序仍然没有收到用户的电子邮件

ios - Google map 集成 iOS 1.9.0 问题

iphone - 当我尝试以编程方式向 UIView 添加 Slider 时,如果宽度太高,它不会出现

iphone - 如何为 iphone 5 转换 UIView 的现有高度