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

Place Add

You can use the Google Places API for iOS to add a place to Google's Places database. The newly-added place is available to your app after a short time, and is added to a moderation queue for possible addition to Google's Places database and Google Maps.

To make it more likely that the place will pass the moderation process and be added to the Google Places database, the add request should include as much information as possible. In particular, the address, phone number and website are important.

  1. Add a place
  2. Handle multiple place IDs and place ID scoping

Add a place

Create a GMSUserAddedPlace then pass it to GMSPlacesClient addPlace:callback:.

Include the following information when creating the GMSUserAddedPlace:

  • Required: The full textual name of the business, point of interest, or other place. Limited to 255 characters.
  • Required: The human-readable address of the place. If a place has a well-formatted, human-readable address, it is more likely to pass the moderation process for inclusion in the Google Places database.
  • Required: A coordinate (CLLocationCoordinate2D) object specifying the location of the place.
  • Optional: The phoneNumber of the place. This is the phone number in international format. International format includes the country code, and is prefixed with the plus (+) sign. For example, the international phone number for Google's Mountain View, USA office is +1 650-253-0000. If a place has a well-formatted phone number, it is more likely to pass the moderation process for inclusion in the Google Places database. Note: You must provide either the phoneNumber or the website, or both.
  • Required: A list of place types that characterize this place. Only table 1 types are valid.
  • Optional: A website URI containing the address of the authoritative website for this place, such as a business home page. If a place has a well-formatted website address, it is more likely to pass the moderation process for inclusion in the Google Places database. Note: You must provide either the phoneNumber or the website, or both.

Also include a callback method to handle the results. The API invokes the specified callback method, passing in the resulting GMSPlace object for the newly-created place.

The following code sample adds a place named 'Google Shoes!' in Pyrmont, Australia.

Swift

let userAddedPlace = GMSUserAddedPlace()
userAddedPlace.name = "Google Shoes!"
userAddedPlace.address = "48 Pirrama Road, Pyrmont, NSW 2009, Australia"
userAddedPlace.coordinate = CLLocationCoordinate2DMake(-33.8669710, 151.1958750)
userAddedPlace.phoneNumber = "(02) 9374 4000"
userAddedPlace.website = "http://www.google.com.au/"
userAddedPlace.types = ["shoe_store"]
placesClient.add(userAddedPlace, callback: { (place, error) -> Void in
  if let error = error {
    print("Add Place error: \(error.localizedDescription)")
    return
  }

  if let place = place {
    print("Added place with placeID \(place.placeID)")
    print("Added Place name \(place.name)")
    print("Added Place address \(place.formattedAddress)")
  }
})

Objective-C

GMSUserAddedPlace *userAddedPlace = [[GMSUserAddedPlace alloc] init];
userAddedPlace.name = @"Google Shoes!";
userAddedPlace.address = @"48 Pirrama Road, Pyrmont, NSW 2009, Australia";
userAddedPlace.coordinate = CLLocationCoordinate2DMake(-33.8669710, 151.1958750);
userAddedPlace.phoneNumber = @"(02) 9374 4000";
userAddedPlace.website = @"http://www.google.com.au/";
userAddedPlace.types = @[@"shoe_store"];

[_placesClient addPlace:userAddedPlace callback:^(GMSPlace *place, NSError *error) {
  if (error != nil) {
    NSLog(@"User Added Place error %@", [error localizedDescription]);
    return;
  }

  NSLog(@"Added place with placeID %@", place.placeID);
  NSLog(@"Added Place name %@", place.name);
  NSLog(@"Added Place address %@", place.formattedAddress);
}];

The resulting GMSPlace object has a unique place ID, which your app can use from that point on to retrieve the place details. Added places are also available after a short time in the results of get-current-place requests initiated by your app, and in a place picker displayed by your app. Scoping is determined by the project ID used to generate your API key.

Newly-added places enter a moderation queue to be considered for addition to the Google Places database. Places that are not accepted by the moderation process will continue to be retrievable through the place ID in the app that submitted them, but will no longer appear in the results of get-current-place requests, the api picker, or any other API method. Places that pass moderation will be visible to all apps and on Google Maps.

Handle multiple place IDs and place ID scoping

Each place ID can refer to only one place, but a single place can have more than one place ID. The most common case for handling multiple IDs for a place is when you've added a place that's initially scoped to your app, and then receives a Google-wide scope.

When you add a place, you receive a place ID for the new place immediately. This place ID is scoped for your app only. The place then enters a moderation queue, awaiting approval for addition to the Google Places database. If approved, the place will receive a new place ID, available to all apps and on Google Maps.

When you request a place by specifying a place ID, you can be confident that you will always receive the same place in the response (if the place still exists).

Note, however, that the response may contain a place ID that is different from the one in your request. For more information, see the place ID overview.

Send feedback about...

location_on
Google Places API for iOS