Google Maps SDK for iOS

Getting Started

Before you can begin working with Google Maps on iOS, you will need to download the Google Maps SDK for iOS and ensure that you have an API key.

Getting the Google Maps SDK for iOS

The Google Maps SDK for iOS is distributed as a zip file containing a static framework. After downloading the SDK, you will need to obtain an API key before you can add a map to your application.

Complete release notes are available for each release.

The Google Maps API Key

Using an API key enables you to monitor your application's Maps API usage, and ensures that Google can contact you about your application if necessary. The key is free, you can use it with any of your applications that call the Maps API, and it supports an unlimited number of users. You obtain a Maps API key from the Google APIs Console by providing your application's bundle identifier. Once you have the key, you add it to your AppDelegate as described in the next section.

The Google Maps URL scheme is available without an API key.

Obtaining an API Key

You can obtain a key for your app in the Google Developers Console.

  1. Create an API project in the Google Developers Console.
  2. Select the Services pane in your API project, and enable the Google Maps SDK for iOS. This displays the Google Maps Terms of Service.
  3. Select the API Access pane in the console, and click Create new iOS key.
  4. Enter one or more bundle identifiers as listed in your application's .plist file, such as com.example.myapp.
  5. Click Create.
  6. In the API Access page, locate the section Key for iOS apps (with bundle identifiers) and note or copy the 40-character API key.

You should repeat this process for each new application.

Adding the Google Maps SDK for iOS to your project

The Google Maps SDK for iOS is packaged as a static framework with an included resource bundle. Before you can add a map to your application, you will need to add the framework to your project, and configure your build settings in Xcode. These instructions assume an installation for a new project. If you are working with an existing project, you may not have to follow the steps exactly as described.

  1. Launch Xcode and either open an existing project, or create a new project.
    • If you're new to iOS, create a Single View Application, and ensure that Use Automatic Reference Counting is on.
  2. Drag the GoogleMaps.framework bundle to your project. When prompted, select Copy items into destination group's folder.
  3. Right-click GoogleMaps.framework in your project, and select Show In Finder.
  4. Drag the GoogleMaps.bundle from the Resources folder to your project. When prompted, ensure Copy items into destination group's folder is not selected.
  5. Select your project from the Project Navigator, and choose your application's target.
  6. Open the Build Phases tab, and within Link Binary with Libraries, add the following frameworks:
    • AVFoundation.framework
    • CoreData.framework
    • CoreLocation.framework
    • CoreText.framework
    • GLKit.framework
    • ImageIO.framework
    • libc++.dylib
    • libicucore.dylib
    • libz.dylib
    • OpenGLES.framework
    • QuartzCore.framework
    • SystemConfiguration.framework
  7. Choose your project, rather than a specific target, and open the Build Settings tab.
    • In the Other Linker Flags section, add -ObjC. If these settings are not visible, change the filter in the Build Settings bar from Basic to All.
  8. Finally, add your API key to your AppDelegate.
    • #import <GoogleMaps/GoogleMaps.h>
    • Add the following to your application:didFinishLaunchingWithOptions: method, replacing API_KEY with your API key.
      [GMSServices provideAPIKey:@"API_KEY"];

Upgrade from an earlier version

To upgrade an existing project to the most recent version of the SDK, do the following:

  1. In the Project Navigator, replace the previous framework with the most recent framework.
  2. (Optional) Make any necessary changes as a result of the upgrade. Necessary changes will be described in the release notes.
  3. Clean and rebuild your project by selecting: Product > Clean and then Product > Build.

Add a Map

After adding the SDK to your project, and adding your key, you can try adding a map to your application. The code below demonstrates how to add a simple map to an existing ViewController. If you're creating a new app to iOS, first follow the installation instructions above, and create a new Single View Application. Be sure to enable Use Automatic Reference Counting (ARC) if your application is written in Objective-C.

Now, add or update a few methods inside your app's default ViewController to create and initialize an instance of GMSMapView.


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

@implementation YourViewController {
  GMSMapView *mapView_;

- (void)viewDidLoad {
  // 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
  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_;



import UIKit

class YourViewController: UIViewController {

  override func viewDidLoad() {

    var camera = GMSCameraPosition.cameraWithLatitude(-33.86,
        longitude: 151.20, zoom: 6)
    var mapView = GMSMapView.mapWithFrame(CGRectZero, camera: camera)
    mapView.myLocationEnabled = true
    self.view = mapView

    var marker = GMSMarker()
    marker.position = CLLocationCoordinate2DMake(-33.86, 151.20)
    marker.title = "Sydney"
    marker.snippet = "Australia"
    marker.map = mapView

Note: Replace both instances of YourViewController in the above example with the name of your View Controller.

Run your application. You should see a map with a single marker centered over Sydney, Australia. If you see the marker, but the map is not visible, confirm that you have provided your API key.

Video: Getting started with the Google Maps SDK for iOS

In this three-part series, Mano Marks walks you through getting set-up with the Google Maps SDK for iOS. The videos cover:

  1. Setting up your development environment.
  2. Getting and testing an API key.
  3. Creating your first application.

For more videos like these, visit the Google Maps Developers Live page.