2017-03-14 15 views
1

Google Maps SDKだけを統合した新しいシングルビュープロジェクトを開始しました。ViewController内でGoogleマップアプリのサイズを設定するにはどうすればよいですか?

現在、すべての画面に表示されています(フルサイズ)。これはデフォルト設定です。私はそれを減らして、トップバーのスペースを取らないようにしたいと思っています。また、ボタンの底にスペースを残したいと思っています。どうすればいいですか?

は、ここに私の(シングル)View Controllerクラスで実装唯一の方法だ:

- (void)loadView { 
// Create a GMSCameraPosition that tells the map to display the 
// coordinate -33.86,151.20 at zoom level 6. 
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86 
                 longitude:151.20 
                  zoom:6]; 
GMSMapView *mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera]; 
mapView.myLocationEnabled = YES; 
self.view = mapView; 

// Creates a marker in the center of the map. 
GMSMarker *marker = [[GMSMarker alloc] init]; 
marker.position = CLLocationCoordinate2DMake(-33.86, 151.20); 
marker.title = @"Sydney"; 
marker.snippet = @"Australia"; 
marker.map = mapView; 
} 

答えて

2
1)Add a UIView into the ViewController where you want and set your custom size 
2)set it's type to be GMSMapView in IdentityInspector 

はファイル.HにIBOutletをdelcare

@property (weak, nonatomic) IBOutlet GMSMapView *map1; 

.M

- (void)viewDidLoad { 
    [super viewDidLoad]; 
    GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:1.285 
                   longitude:103.848 
                    zoom:12]; 
     self.map1.camera = camera; 
     self.map1.delegate=self; 
     self.map1.accessibilityElementsHidden = NO; 
     self.map1.indoorEnabled = NO; 
     self.map1.settings.myLocationButton = YES; 
     dispatch_async(dispatch_get_main_queue(), ^{ 
      self.map1.myLocationEnabled = YES; 
     }); 
} 

このブログをチェックするhttp://vikrambahl.com/google-maps-ios-xcode-storyboards/

+0

は、各ラインのエラーを得た:メンバ参照ベース型「int型*」は、あなたがエラーを得たラインkonyv12 @構造体や共用体 – konyv12

+0

ではないと言います? – iOS

+0

for each .. – konyv12

0

それはこの

GMSMapView *mapView = [GMSMapView mapWithFrame:CGRectMake(0, 64, [[UIScreen mainScreen] bounds].size.width, [[UIScreen mainScreen] bounds].size.height -200) camera:camera]; 

//底面図の高さなどのようにする必要があります:200ここ

0

その後、(ストーリーボードを使用して)、次の手順に従ってビューコントローラの限られた一部のGoogleマップを追加するには:

  1. を既存のUIViewControllerに追加します。
  2. カスタネットクラスでは、UIViewのカスタムクラスとしてGMSMapViewを追加します。 enter image description here

  3. IBOutletをUIViewにmapViewとして作成します。

    @property (weak, nonatomic) IBOutlet GMSMapView *mapView; 
    
  4. mapViewに高さ/幅または拘束を与えます。

  5. あなたの関数は次のようになります。

    - (void)loadView { 
    // Create a GMSCameraPosition that tells the map to display the 
    // coordinate -33.86,151.20 at zoom level 6. 
        GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86 
                    longitude:151.20 
                     zoom:6]; 
        self.mapView.myLocationEnabled = YES; 
    
        // Creates a marker in the center of the map. 
        GMSMarker *marker = [[GMSMarker alloc] init]; 
        marker.position = CLLocationCoordinate2DMake(-33.86, 151.20); 
        marker.title = @"Sydney"; 
        marker.snippet = @"Australia"; 
        marker.map = self.mapView; 
    } 
    
関連する問題