IOS Swift API Google how to set up placePicker

google

IOS

GMSPlacePicker

Is there anyway we can customize ? for example, change the image of a pin or disable labels like restaurants, bars or even add buttons above it?

Many thanks.

+3


source to share


2 answers


The only suggested setting is inside the GMSPlacePickerConfig class - it allows you to change the viewport , far from what you are looking for.



+1


source


Google recently updated their API and GMSPlacePicker is now deprecated (support stops May 2018), giving you a little time to migrate everything to your application.

Note. The implementation of placement selection has changed. Starting with version 2.3 of the Google Places API for iOS, the GMSPlacePicker class has been deprecated, replaced by the GMSPlacePickerViewController. The use of the GMSPlacePicker class will only be supported until May 1, 2018. We recommend that you update your code to use the GMSPlacePickerViewController whenever possible.

To access this new feature, go to version 2.3.

The new system is relatively easy to implement. You now confirm:

GMSPlacePickerViewControllerDelegate

And you have access to a method like didPick () or didCancel () ...

The good thing when it comes to customizing your UI is that since everything is now controlled by the ViewController, you can add it to your navigation controller stack, for example, and it can inherit from the navigation bar design you have set on other ViewControllers that are also on your stack before or after placePicker.



I'm at work right now, but I'll edit my answer later with sample code.

See documentation here for more details: https://developers.google.com/places/ios-api/placepicker

And when you set your placePicker, be sure to point your delegate to yourself to make sure the didPick / didCancel methods fire correctly. If you forget, you will receive the following warning when you try to select or deselect a collector. This is not written in the documentation, but obviously necessary.

Places API Warning: Delegate was not set on a GMSPlacePickerViewController instance prior to use. Note that this can lead to undefined behavior such as the inability to reject screens, rather than being notified of the selection and unable to properly manipulate the Lifecycle object.

Hope this helps.

Ed

0


source







All Articles