我正在尝试将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/

10-11 22:54