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

GMSPlacesClient Class Reference


Overview

Main interface to the Places API.

Used for searching and getting details about places. This class should be accessed through the [GMSPlacesClient sharedClient] method.

GMSPlacesClient methods should only be called from the main thread. Calling these methods from another thread will result in an exception or undefined behavior. Unless otherwise specified, all callbacks will be invoked on the main thread.

Public Member Functions

(void) - reportDeviceAtPlaceWithID:
 Report that the device is at a particular place.
(void) - lookUpPlaceID:callback:
 Get details for a place.
(void) - lookUpPhotosForPlaceID:callback:
 Gets the metadata for up to 10 photos associated with a place.
(void) - loadPlacePhoto:callback:
 Loads the image for a specific photo at its maximum size.
(void) - loadPlacePhoto:constrainedToSize:scale:callback:
 Loads the image for a specific photo, scaled to fit the given maximum dimensions.
(void) - currentPlaceWithCallback:
 Returns an estimate of the place where the device is currently known to be located.
(void) - autocompleteQuery:bounds:filter:callback:
 Autocompletes a given text query.
(void) - autocompleteQuery:bounds:boundsMode:filter:callback:
 Autocompletes a given text query.
(void) - addPlace:callback:
 Add a place.

Static Public Member Functions

(instancetype) + sharedClient
 Provides the shared instance of GMSPlacesClient for the Google Places API for iOS, creating it if necessary.
(BOOL) + provideAPIKey:
 Provides your API key to the Google Places API for iOS.
(NSString *) + openSourceLicenseInfo
 Returns the open source software license information for the Google Places API for iOS.
(NSString *) + SDKVersion
 Returns the version for this release of the Google Places API for iOS.

Related Functions

(Note that these are not member functions.)

typedef void(^ GMSPlaceResultCallback )(GMSPlace *_Nullable result, NSError *_Nullable error)
 Callback type for receiving place details lookups.
typedef void(^ GMSPlaceLikelihoodListCallback )(GMSPlaceLikelihoodList *_Nullable likelihoodList, NSError *_Nullable error)
 Callback type for receiving place likelihood lists.
typedef void(^ GMSAutocompletePredictionsCallback )(NSArray< GMSAutocompletePrediction * > *_Nullable results, NSError *_Nullable error)
 Callback type for receiving autocompletion results.
typedef void(^ GMSPlacePhotoMetadataResultCallback )(GMSPlacePhotoMetadataList *_Nullable photos, NSError *_Nullable error)
 Callback type for receiving place photos results.
typedef void(^ GMSPlacePhotoImageResultCallback )(UIImage *_Nullable photo, NSError *_Nullable error)
 Callback type for receiving UIImage objects from a GMSPlacePhotoMetadata object.

Member Function Documentation

+ (instancetype) sharedClient

Provides the shared instance of GMSPlacesClient for the Google Places API for iOS, creating it if necessary.

If your application often uses methods of GMSPlacesClient it may want to hold onto this object directly, as otherwise your connection to Google may be restarted on a regular basis.

+ (BOOL) provideAPIKey: (NSString *)  key

Provides your API key to the Google Places API for iOS.

This key is generated for your application via the Google APIs Console, and is paired with your application's bundle ID to identify it. This should be called exactly once by your application, e.g., in application: didFinishLaunchingWithOptions:.

Returns:
YES if the APIKey was successfully provided.
+ (NSString *) openSourceLicenseInfo

Returns the open source software license information for the Google Places API for iOS.

This information must be made available within your application.

+ (NSString *) SDKVersion

Returns the version for this release of the Google Places API for iOS.

- (void) reportDeviceAtPlaceWithID: (NSString *)  placeID

Report that the device is at a particular place.

- (void) lookUpPlaceID: (NSString *)  placeID
callback: (GMSPlaceResultCallback callback 

Get details for a place.

This method is non-blocking.

Parameters:
placeIDThe place ID to lookup.
callbackThe callback to invoke with the lookup result.
- (void) lookUpPhotosForPlaceID: (NSString *)  placeID
callback: (GMSPlacePhotoMetadataResultCallback callback 

Gets the metadata for up to 10 photos associated with a place.

Photos are sourced from a variety of locations, including business owners and photos contributed by Google+ users. In most cases, these photos can be used without attribution, or will have the required attribution included as a part of the image. However, you must use the attributions property in the response to retrieve any additional attributions required, and display those attributions in your application wherever you display the image. A maximum of 10 photos is returned.

Multiple calls of this method will probably return the same photos each time. However, this is not guaranteed because the underlying data may have changed.

This method performs a network lookup.

Parameters:
placeIDThe place ID for which to lookup photos.
callbackThe callback to invoke with the lookup result.
- (void) loadPlacePhoto: (GMSPlacePhotoMetadata *)  photo
callback: (GMSPlacePhotoImageResultCallback callback 

Loads the image for a specific photo at its maximum size.

Image data may be cached. If the requested photo does not exist in the cache then a network lookup will be performed.

Parameters:
photoThe photo for which to load a UIImage.
callbackThe callback to invoke with the loaded UIImage.
- (void) loadPlacePhoto: (GMSPlacePhotoMetadata *)  photo
constrainedToSize: (CGSize)  maxSize
scale: (CGFloat)  scale
callback: (GMSPlacePhotoImageResultCallback callback 

Loads the image for a specific photo, scaled to fit the given maximum dimensions.

The image will be scaled to fit within the given dimensions while maintaining the aspect ratio of the original image. This scaling is performed server-side.

If the scale parameter is not 1.0 maxSize will be multiplied by this value and the returned UIImage will be set to have the specified scale. This parameter should be set to the screen scale if you are loading images for display on screen.

Image data may be cached. If the requested photo does not exist in the cache then a network lookup will be performed.

Note:
After applying the scale factor the dimensions in maxSize will be rounded up to the nearest integer before use. If an image is requested which is larger than the maximum size available a smaller image may be returned.
Parameters:
photoThe photo for which to load a UIImage.
maxSizeThe maximum size of the image.
scaleThe scale to load the image at.
callbackThe callback to invoke with the loaded UIImage.

Returns an estimate of the place where the device is currently known to be located.

Generates a place likelihood list based on the device's last estimated location. The supplied callback will be invoked with this likelihood list upon success and an NSError upon an error.

Note:
This method requires that your app has permission to access the current device location. Before calling this make sure to request access to the users location using [CLLocationManager requestWhenInUseAuthorization] or [CLLocationManager requestAlwaysAuthorization]. If you do call this method and your app does not have the correct authorization status, the callback will be called with an error.
Parameters:
callbackThe callback to invoke with the place likelihood list.
- (void) autocompleteQuery: (NSString *)  query
bounds: (nullable GMSCoordinateBounds *)  bounds
filter: (nullable GMSAutocompleteFilter *)  filter
callback: (GMSAutocompletePredictionsCallback callback 

Autocompletes a given text query.

Results may optionally be biased towards a certain location.

The supplied callback will be invoked with an array of autocompletion predictions upon success and an NSError upon an error.

Parameters:
queryThe partial text to autocomplete.
boundsThe bounds used to bias the results. This is not a hard restrict - places may still be returned outside of these bounds. This parameter may be nil.
filterThe filter to apply to the results. This parameter may be nil.
callbackThe callback to invoke with the predictions.
- (void) autocompleteQuery: (NSString *)  query
bounds: (nullable GMSCoordinateBounds *)  bounds
boundsMode: (GMSAutocompleteBoundsMode boundsMode
filter: (nullable GMSAutocompleteFilter *)  filter
callback: (GMSAutocompletePredictionsCallback callback 

Autocompletes a given text query.

Results may optionally be biased towards a certain location, or restricted to an area.

The supplied callback will be invoked with an array of autocompletion predictions upon success and an NSError upon an error.

Parameters:
queryThe partial text to autocomplete.
boundsThe bounds used to bias or restrict the results. Whether this biases or restricts is determined by the value of the boundsMode parameter. This parameter may be nil.
boundsModeHow to treat the bounds parameter. Has no effect if bounds is nil.
filterThe filter to apply to the results. This parameter may be nil.
callbackThe callback to invoke with the predictions.
- (void) addPlace: (GMSUserAddedPlace *)  place
callback: (GMSPlaceResultCallback callback 

Add a place.

The place must have all its fields set, except that website or phoneNumber may be nil.

Parameters:
placeThe details of the place to be added.
callbackThe callback to invoke with the place that was added.
Note:
The Add Place feature is deprecated as of June 30, 2017. This feature will be turned down on June 30, 2018, and will no longer be available after that date.
This is deprecated. The Add Place feature is deprecated as of June 30, 2017. This feature will be turned down on June 30, 2018, and will no longer be available after that date.

Friends And Related Function Documentation

- (typedef void(^ GMSPlaceResultCallback)(GMSPlace *_Nullable result, NSError *_Nullable error)) [related]

Callback type for receiving place details lookups.

If an error occurred, result will be nil and error will contain information about the error.

Parameters:
resultThe GMSPlace that was returned.
errorThe error that occurred, if any.
- (typedef void(^ GMSPlaceLikelihoodListCallback)(GMSPlaceLikelihoodList *_Nullable likelihoodList, NSError *_Nullable error)) [related]

Callback type for receiving place likelihood lists.

If an error occurred, likelihoodList will be nil and error will contain information about the error.

Parameters:
likelihoodListThe list of place likelihoods.
errorThe error that occurred, if any.
- (typedef void(^ GMSAutocompletePredictionsCallback)(NSArray< GMSAutocompletePrediction * > *_Nullable results, NSError *_Nullable error)) [related]

Callback type for receiving autocompletion results.

results is an array of GMSAutocompletePredictions representing candidate completions of the query.

Parameters:
resultsAn array of GMSAutocompletePredictions.
errorThe error that occurred, if any.
- (typedef void(^ GMSPlacePhotoMetadataResultCallback)(GMSPlacePhotoMetadataList *_Nullable photos, NSError *_Nullable error)) [related]

Callback type for receiving place photos results.

If an error occurred, photos will be nil and error will contain information about the error.

Parameters:
photosThe result containing GMSPlacePhotoMetadata objects.
errorThe error that occurred, if any.
- (typedef void(^ GMSPlacePhotoImageResultCallback)(UIImage *_Nullable photo, NSError *_Nullable error)) [related]

Callback type for receiving UIImage objects from a GMSPlacePhotoMetadata object.

If an error occurred, photo will be nil and error will contain information about the error.

Parameters:
photoThe UIImage which was loaded.
errorThe error that occurred, if any.

Send feedback about...

location_on
Google Places API for iOS