Help us understand the problem. What is going on with this article?

Google Maps SDK for iOSを使う

More than 5 years have passed since last update.

1. API Keyの取得

1. Google Maps SDK for iOSのステータスをonにする

Google APIs Consoleで画面左のServicesを選択し、Google Maps SDK for iOSのステータスをonにする。

2. API Keyを取得

Google APIs Consoleで画面左のAPI Accessを選択し、Create new iOS keyをクリック。アプリのbundle identifiersを入力し、Createをクリック

2. SDKの追加

1. Google Maps SDK for iOSダウンロード
Version 1.3.1からSDKをダウンロードする。

2. GoogleMaps.framework追加
GoogleMaps.frameworkフォルダをXcodeのFrameworksにドラッグアンドドロップ。(Copy items into destination group's folderにチェックをつける)

3. GoogleMaps.bundle追加
Xcode上で2で追加したGoogleMaps.frameworkを右クリックし、Show In Finderを選択。Resourcesフォルダの中にあるGoogleMaps.bundleをXcodeのFrameworksにドラッグアンドドロップ。Copy items into destination group's folderのチェックをはずす)

4. その他のフレームワークを追加


5. Build Settingsの変更
TARGETSのBuild Settingsを開き以下の2つを変更

・Other Linker Flagsを-ObjCに設定

6. AppDelegate編集

GoogleMaps.hをインポートし、application:didFinishLaunchingWithOptions:メソッド内で取得したAPI Keyを設定。

# -----------略-----------
#import <GoogleMaps/GoogleMaps.h>

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    // Override point for customization after application launch.
    [GMSServices provideAPIKey:@"AIzaSyB7-kCq7IriVPLeSXo6d3NQ1-s-w86iBB4"];
    return YES;
# -----------略-----------

3. サンプルを動かす


#import "ViewController.h"
#import <GoogleMaps/GoogleMaps.h>

@interface ViewController ()


@implementation ViewController {
    GMSMapView *mapView_;

- (void)viewDidLoad
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86
    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"; = mapView_;

- (void)didReceiveMemoryWarning
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.





Google Maps SDK for iOS

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away