Skip to content

nafetswirth/ios_google_places_autocomplete

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GooglePlacesAutocomplete

Build Status CocoaPod

A simple Google Places API autocompleting address entry view for iOS devices.

There are already a couple of solutions out there for this. GooglePlacesAutocomplete is different because it is 100% Swift, and aims to provide the simplest possible method of entering validated, autocompleted addresses.

No attempt has been made to integrate MapKit since displaying Google Places on a non-Google map is against their terms of service.


Requirements

  • iOS 7.0+
  • XCode 6.1

Installation

Embedded frameworks require a minimum deployment target of iOS 8.

To use GooglePlacesAutocomplete with a project targeting iOS 7, you must include the source files directly in your project. See the 'manual installation' section for instructions.

CocoaPods

CocoaPods is a dependency manager for Cocoa projects.

CocoaPods 0.36 beta adds supports for Swift and embedded frameworks. You can install it with the following command:

$ gem install cocoapods --pre

To integrate GooglePlacesAutocomplete into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'

pod 'GooglePlacesAutocomplete'

Then, run the following command:

$ pod install

Manual

Simply copy GooglePlacesAutocomplete.swift and GooglePlacesAutocomplete.xib to your project.

Note: Don't forget to add the PoweredByGoogle image to your xcassets.

Usage

import GooglePlacesAutocomplete // Not required when including source files directly in project

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

gpaViewController.placeDelegate = self // Conforms to GooglePlacesAutocompleteDelegate

presentViewController(gpaViewController, animated: true, completion: nil)

GooglePlacesAutocompleteDelegate supports three methods:

  • placesFound(places: [Place]): Invoked whenever the Google Places API is called
  • placeSelected(place: Place): Invoked when a new place is selected
  • placeViewClosed(): Invoked when the view is closed

Here's a complete example.

Contributing

  1. Fork it ( https://github.com/watsonbox/ios-google-places-autocomplete/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

About

Google Places address entry for iOS (Swift)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 79.0%
  • Ruby 16.0%
  • C++ 2.9%
  • Objective-C 2.1%