You're all set!

To start developing, please head over to our developer documentation.

Activate the Google Places API for iOS

To get you started we'll guide you through the Google Developers Console to do a few things first:

  1. Create or choose a project
  2. Activate the Google Places API for iOS
  3. Create appropriate keys
Continue

Displaying Attributions

When displaying data from the Google Places API for iOS, such as autocomplete results or place name and address, there are some attribution and Google logo requirements you must comply with.

Overview

The attribution and logo requirements fall into the following categories:

The requirements apply to the place picker UI widget as well as the programmatic API calls. If the app has retrieved a place via the place picker and then shows the data on a follow-up screen without a map, the app must show attributions on the follow-up screen.

Displaying a map

You do not need to display a map. If your application displays data from the Google Places API for iOS on a map, that map must be a Google map with the Google logo visible. Applications that display Places API data on the same screen as a Google map are not required to provide further attribution to Google.

Note that you're still required to display any relevant attributions for third-party content.

The 'Powered by Google' attribution

If your application displays Places API data on a page or view without a Google Map, you must show a 'Powered by Google' image with that data. For example, if your application displays a list of places retrieved by the API on one screen, and a Google Map with those places on another screen, the first screen must show the 'Powered by Google' attribution.

The following ZIP file contains the 'Powered by Google' image in the correct sizes for desktop, Android and iOS applications. You may not resize or modify these images in any way.

Download: powered-by-google.zip
  • For use on a light background: powered-by-google-on-white<size-indicator>.png
  • For use on a dark background: powered-by-google-on-non-white<size-indicator>.png

Attributions for third-party content

Attributions to third-party providers contain content that you must display to the user in the format in which they are provided. Any links included in the attribution must be preserved. We recommend that your app shows this information below the place details.

Follow these instructions to retrieve third-party attributions for a single place or a collection of places.

Retrieving attributions for a single place

When you retrieve a place from the place picker or from getting a place by ID, you can retrieve the attributions for that place from the attributions property on GMSPlace .

The attributions are provided as an NSAttributedString object.

The following code offers a basic example of how to display attributions for a single place retrieved from the place picker.

Swift

  @IBOutlet weak var nameLabel: UILabel!
  @IBOutlet weak var attributionTextView: UITextView!

  var placePicker: GMSPlacePicker?

  override func viewDidLoad() {
    super.viewDidLoad()
    attributionTextView.delegate = self
  }

  // Select the PARKROYAL Saigon
  let VIEWPORT_LATLNG = CLLocationCoordinate2DMake(10.800174,106.667622)
  let VIEWPORT_DELTA = 0.001

  @IBAction func pickPlace(sender: UIButton) {
    let northEast = CLLocationCoordinate2DMake(VIEWPORT_LATLNG.latitude + VIEWPORT_DELTA, VIEWPORT_LATLNG.longitude + VIEWPORT_DELTA)
    let southWest = CLLocationCoordinate2DMake(VIEWPORT_LATLNG.latitude - VIEWPORT_DELTA, VIEWPORT_LATLNG.longitude - VIEWPORT_DELTA)
    let viewport = GMSCoordinateBounds(coordinate: northEast, coordinate: southWest)
    let config = GMSPlacePickerConfig(viewport: viewport)
    placePicker = GMSPlacePicker(config: config)

    placePicker?.pickPlaceWithCallback({ (place: GMSPlace?,error: NSError?) -> Void in
      self.nameLabel.text = ""
      self.attributionTextView.text = ""

      if error != nil {
        self.nameLabel.text = error?.localizedDescription
        return
      }

      if place != nil {
        self.nameLabel.text = place?.name
        self.attributionTextView.attributedText = place?.attributions
      } else {
        self.nameLabel.text = "No place selected"
      }
    })
  }
    

Objective-C

@interface ViewController () <UITextViewDelegate>
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UITextView *attributionTextView;
@end

@implementation ViewController {
  GMSPlacePicker *_placePicker;
}

- (void)viewDidLoad {
  [super viewDidLoad];
  self.attributionTextView.delegate = self;
}

- (IBAction)pickPlace:(UIButton *)sender {
  // Select the PARKROYAL Saigon
  CLLocationCoordinate2D VIEWPORT_LATLNG = CLLocationCoordinate2DMake(10.800174,106.667622);
  float VIEWPORT_DELTA = 0.001;

  CLLocationCoordinate2D northEast = CLLocationCoordinate2DMake(VIEWPORT_LATLNG.latitude + VIEWPORT_DELTA,
                                                                VIEWPORT_LATLNG.longitude + VIEWPORT_DELTA);
  CLLocationCoordinate2D southWest = CLLocationCoordinate2DMake(VIEWPORT_LATLNG.latitude - VIEWPORT_DELTA,
                                                                VIEWPORT_LATLNG.longitude - VIEWPORT_DELTA);
  GMSCoordinateBounds *viewport = [[GMSCoordinateBounds alloc] initWithCoordinate:northEast
                                                                       coordinate:southWest];
  GMSPlacePickerConfig *config = [[GMSPlacePickerConfig alloc] initWithViewport:viewport];
  _placePicker = [[GMSPlacePicker alloc] initWithConfig:config];

  [_placePicker pickPlaceWithCallback:^(GMSPlace *place, NSError *error) {
    self.nameLabel.text = @"";
    self.attributionTextView.text = @"";

    if (error != nil) {
      self.nameLabel.text = [error localizedDescription];
      return;
    }

    if (place != nil) {
      self.nameLabel.text = place.name;
      self.attributionTextView.attributedText = place.attributions;
    } else {
      self.nameLabel.text = @"No place selected";
    }
  }];
}
    

Retrieving attributions for a collection of places

If your app displays information obtained by requesting the device's current place, the app must display third-party attributions for the place details displayed. You can retrieve the attributions for all the places retrieved in the request, from the attributions property on GMSPlaceLikelihoodList.

The attributions are provided as a NSAttributedString object, which you can access and display in the same way as the attributions on a single place, as described above.

Displaying attributions for a photo

If your app displays photos, you must show attributions for each photo that has them. To get attributions for a photo, call GMSPlacePhotoMetadata.attributions. This property is a NSAttributedString, or nil if there are no attributions to display.

Swift

GMSPlacesClient.sharedClient().lookUpPhotosForPlaceID(placeID) { (photos, error) -> Void in
  if let error = error {
    // TODO: handle the error.
    print("Error: \(error.description)")
  } else {
    // Get attribution for the first photo in the list.
    if let photo = photos?.results.first {
      let attributions = photo.attributions
    }
  }
}
    

Objective-C

[[GMSPlacesClient sharedClient]
    lookUpPhotosForPlaceID:placeID
                  callback:^(GMSPlacePhotoMetadataList *_Nullable photos,
                             NSError *_Nullable error) {
                    if (error) {
                      // TODO: handle the error.
                      NSLog(@"Error: %@", [error description]);
                    } else {
                      // Get attribution for the first photo in the list.
                      if (photos.results.count > 0) {
                        GMSPlacePhotoMetadata *photo = photos.results.firstObject;
                        NSAttributedString *attributions = photo.attributions;
                      }
                    }
                  }];
    

Displaying third-party attributions

Attributions to third-party providers are provided as NSAttributedString objects and contain content with links that you must display to the user. Any links included in the attribution must be preserved.

The recommended way to display the attributions is with a UITextView as links in the attributions must work. To ensure links work set a delegate on the UITextView and set the shouldInteractWithURL method of your UITextViewDelegate to return YES. See the code sample below.

Swift

...
  self.attributionTextView.delegate = self
...

// MARK: - UITextViewDelegate

func textView(textView: UITextView, shouldInteractWithURL URL: NSURL,
  inRange characterRange: NSRange) -> Bool {
  // Make links clickable.
  return true
}
    

Objective-C

...
  self.attributionTextView.delegate = self;
...

#pragma mark - UITextViewDelegate

- (BOOL)textView:(UITextView *)textView
    shouldInteractWithURL:(NSURL *)url
                  inRange:(NSRange)characterRange {
  // Make links clickable.
  return YES;
}
    

Example of a third-party attribution

A third-party attribution typically consists of text with a link. For example:

Listings by Example Company

In the above example, the Example Company text range is covered by an NSLink attribute.

Send feedback about...

location_on
Google Places API for iOS