google places autocomplete ios swift integrate with uitextfield

Niranjan Balkrishna Prajapati picture Niranjan Balkrishna Prajapati · Jan 23, 2016 · Viewed 7.8k times · Source

I am trying to implement google places auto complete api in swift 2.0 project by using the following library:

https://github.com/watsonbox/ios_google_places_autocomplete

the only thing i am not able to figure out is that i want to integrate this with uitextfield present in my app form which has country and city fields.

I have implemented this app in a demo project and found out that it also provides me lat long of the location also.

Please help me out by guiding me to integrate this library with the uitextfield so when user types in uitextfield the results are shown below uitextfield only.

By working to implement code in demo app i came to know that the searchbox opens up with the following code:

let gpaViewController = GooglePlacesAutocomplete(
        apiKey: "API KEY FROM GOOGLE PLACES API",
        placeType: .Address
    )

I am not able to figure out how to get this viewcontroller functionality work on my uitextfield so it can work exactly as it works on uitextfield

Answer

Ankahathara picture Ankahathara · Feb 15, 2016

Why do not use Google Places API for iOS ? It has all the capability as seen on the mentioned library. Here is the link https://developers.google.com/places/ios-api/autocomplete

and you can use the fetcher object to get the predictions and according to whatever requirement you can customize the result. Hope this helps