如何把谷歌MapView的UIView?

我试图把谷歌地图在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_]; 

所以,我得到了解决办法。 不pipe怎么说,还是要谢谢你。

最好的祝福。

解:

 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_]; 

基本上在故事板中,对于相应的View(UIVIew),您将显示Google Map,您必须在身份检查器中将该类设置为GMSMapView

这是视图控制器在Swift 3中的样子。

 class GMapsViewController: UIViewController { @IBOutlet weak var mapContainerView: GMSMapView! override func viewDidLoad() { super.viewDidLoad() let camera = GMSCameraPosition.camera(withLatitude: -33.86, longitude: 151.20, zoom: 6.0) let marker = GMSMarker() marker.position = CLLocationCoordinate2D(latitude: -33.86, longitude: 151.20) marker.title = "Sydney" marker.map = mapContainerView mapContainerView.moveCamera(GMSCameraUpdate.setCamera(camera)) } }