2013-10-04 8 views
8

Google MapViewをUIViewに配置しようとしていますが、何も表示されません。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_]; 

だから、私は解決策を得ました。とにかくありがとう。

よろしくお願いいたします。

+1

に同じような答えのように – Vinodh

答えて

17

ソリューション:ストーリーボードでは基本的に

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

あなたは絶対的に正しいです本当に参考になる受け入れるというポストをどのように見えるかです – IKKA

0

、対応するビュー(UIViewの)ためには、あなたがGoogleマップを表示しようとしている、あなたはアイデンティティインスペクタでGMSMapViewとしてクラスを設定する必要があります。

どうもありがとう。これは、ビューコントローラは、スウィフト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)) 


     } 
} 
関連する問題