Place Picker

Deprecation notice: Place Picker

Notice:
The Place Picker (Android,
iOS) is deprecated as of
January 29, 2019. This feature will be turned off on
July 29, 2019, and will no longer be available after that
date. Read the migration guides to learn more:

The place picker is a simple and yet flexible built-in UI widget, part of the
Places SDK for iOS.

Introducing the place picker

The
GMSPlacePickerViewController
provides a UI that displays an interactive map and a list of nearby
places, including places corresponding to geographical addresses and local
businesses. Users can choose a place, and your app can then retrieve the
details of the selected place.

The place picker provides the following advantages over developing your
own UI widget:

The user experience is consistent with other apps using the place picker,
including Google apps and third parties. This means users of your app
already know how to interact with the place picker.

The map is integrated into the place picker.

Accessibility is built in.

It saves development time.

The place picker features autocomplete functionality, which
displays place predictions based on user search input. This functionality is
present in all place picker integrations, so you don't need to do
anything extra to enable autocomplete. For more information about autocomplete,
see Place Autocomplete.

Quick start: Run
pod try GooglePlacePicker
to try the SDK demo app. For more details, see
Code Samples Overview.

Request location authorization

If your app uses the place picker, you must request permission to use
location services. First add one or both of the following keys to your
Info.plist file, to request 'when in use' or 'always'
authorization:

NSLocationWhenInUseUsageDescription

NSLocationAlwaysUsageDescription

For the place picker, it's enough to request 'when in use' authorization, but
you may want to request 'always' authorization for other functionality in your
app. For each key, add a string informing the user why you need the location
services. For example:

As shown in the above code sample, you can initalize the place picker with a
given configuration using a
GMSPlacePickerConfig
object. If a value of nil is assigned to the viewport, the
place picker will center on the current device location. To center on a
specific location, specify a viewport containing a
GMSCoordinateBounds
object defining the initial rectangular map area to display. The following
example shows creating a GMSCoordinateBounds
to center the map on Sydney, Australia.

As the place picker is a normal view controller it can be displayed any way you want.
For example, in a popover, fullscreen, pushed onto a navigation stack, or even as part of a
custom app UI. Because of this flexibility the place picker is unable to dismiss itself, so your
app must programmatically dismiss it when placePicker(_:didPick:)
is called. In some cases it may be necessary to dismiss the place picker from
placePickerDidCancel(_:)
as well.

Display attributions in your app

When your app displays information obtained via the place picker, the app
must also display attributions. See the documentation on
attributions.

Old Client Libraries

Prior to version 2.3 of the Places SDK for iOS GMSPlacePicker
was the only available way to use the place picker. This class has now been deprecated and it
is recommended that GMSPlacePickerViewController
is used instead. This new class is more flexible and is not limited to being displayed
full-screen.