Skip to content

Commit

Permalink
Update to use GooglePlaces SDK instead of big GoogleMaps
Browse files Browse the repository at this point in the history
  • Loading branch information
mats-claassen committed Jul 29, 2016
1 parent 67b8c56 commit e888be8
Show file tree
Hide file tree
Showing 102 changed files with 1,844 additions and 26 deletions.
2 changes: 1 addition & 1 deletion Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "xmartlabs/Eureka" "1.5.0"
github "xmartlabs/Eureka" "1.6.0"
8 changes: 8 additions & 0 deletions Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
28F828D71C4B714D00330CF4 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 28F828D61C4B714D00330CF4 /* Assets.xcassets */; };
28F828DA1C4B714D00330CF4 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 28F828D81C4B714D00330CF4 /* LaunchScreen.storyboard */; };
8F3EDFA21CBFCE1E000754B7 /* GooglePlacesRow.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 287D0A7A1C4B7B26004566D6 /* GooglePlacesRow.framework */; };
8FCDF8721D4BB4F1005FE478 /* Eureka.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8FCDF8711D4BB4F1005FE478 /* Eureka.framework */; };
8FCDF8731D4BB4F1005FE478 /* Eureka.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 8FCDF8711D4BB4F1005FE478 /* Eureka.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -56,6 +58,7 @@
dstSubfolderSpec = 10;
files = (
287D0A7E1C4B7B55004566D6 /* GooglePlacesRow.framework in Embed Frameworks */,
8FCDF8731D4BB4F1005FE478 /* Eureka.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -74,6 +77,7 @@
28F828DB1C4B714D00330CF4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = Example/Info.plist; sourceTree = "<group>"; };
28F828E01C4B714D00330CF4 /* ExampleUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ExampleUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
28F828E61C4B714D00330CF4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; name = Info.plist; path = Example/ExampleUITests/Info.plist; sourceTree = "<group>"; };
8FCDF8711D4BB4F1005FE478 /* Eureka.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Eureka.framework; path = Carthage/Build/iOS/Eureka.framework; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -82,6 +86,7 @@
buildActionMask = 2147483647;
files = (
8F3EDFA21CBFCE1E000754B7 /* GooglePlacesRow.framework in Frameworks */,
8FCDF8721D4BB4F1005FE478 /* Eureka.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -149,6 +154,7 @@
8F3EDFA11CBFCDCB000754B7 /* Frameworks */ = {
isa = PBXGroup;
children = (
8FCDF8711D4BB4F1005FE478 /* Eureka.framework */,
);
name = Frameworks;
sourceTree = "<group>";
Expand Down Expand Up @@ -435,6 +441,7 @@
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Frameworks",
"$(PROJECT_DIR)/Carthage/Build/iOS",
);
INFOPLIST_FILE = "$(SRCROOT)/Example/Example/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
Expand All @@ -451,6 +458,7 @@
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Frameworks",
"$(PROJECT_DIR)/Carthage/Build/iOS",
);
INFOPLIST_FILE = "$(SRCROOT)/Example/Example/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
Expand Down
5 changes: 3 additions & 2 deletions Example/Example/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//

import UIKit
import GoogleMaps
import GooglePlaces

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
Expand All @@ -17,7 +17,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
//TODO: Set API_KEY
let apiKey = "YOUR_API_KEY"
GMSServices.provideAPIKey(apiKey)
GMSPlacesClient.provideAPIKey(apiKey)
print(GMSPlacesClient.openSourceLicenseInfo())
if apiKey == "YOUR_API_KEY" {
print("IF YOU SEE THIS IN YOUR CONSOLE IT'S BECAUSE YOU FORGOT TO SET YOUR API_KEY")
assertionFailure()
Expand Down
2 changes: 1 addition & 1 deletion Example/Example/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import UIKit
import GooglePlacesRow
import Eureka
import GoogleMaps
import GooglePlaces

class ViewController: FormViewController {

Expand Down
1 change: 1 addition & 0 deletions Frameworks/GoogleMapsBase.framework/GoogleMapsBase
1 change: 1 addition & 0 deletions Frameworks/GoogleMapsBase.framework/Headers
1 change: 1 addition & 0 deletions Frameworks/GoogleMapsBase.framework/Modules
1 change: 1 addition & 0 deletions Frameworks/GoogleMapsBase.framework/Resources
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//
// GMSCompatabilityMacros.h
// Google Maps SDK for iOS
//
// Copyright 2015 Google Inc.
//
// Usage of this SDK is subject to the Google Maps/Google Earth APIs Terms of
// Service: https://developers.google.com/maps/terms
//

#import <Foundation/Foundation.h>

#if !__has_feature(nullability) || !defined(NS_ASSUME_NONNULL_BEGIN) || \
!defined(NS_ASSUME_NONNULL_END)
#define GMS_ASSUME_NONNULL_BEGIN
#define GMS_ASSUME_NONNULL_END
#define GMS_NULLABLE
#define GMS_NULLABLE_PTR
#define GMS_NULLABLE_INSTANCETYPE instancetype
#else
#define GMS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
#define GMS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
#define GMS_NULLABLE nullable
#define GMS_NULLABLE_PTR __nullable
#define GMS_NULLABLE_INSTANCETYPE nullable instancetype
#endif

#if __has_feature(objc_generics) && defined(__IPHONE_9_0) && \
__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_9_0
#define GMS_DECLARE_GENERICS 1
#else
#define GMS_DECLARE_GENERICS 0
#endif

#if GMS_DECLARE_GENERICS
#define GMS_NSArrayOf(value) NSArray<value>
#define GMS_NSDictionaryOf(key, value) NSDictionary<key, value>
#define GMS_NSSetOf(value) NSSet<value>
#else
#define GMS_NSArrayOf(value) NSArray
#define GMS_NSDictionaryOf(key, value) NSDictionary
#define GMS_NSSetOf(value) NSSet
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
//
// GMSCoordinateBounds.h
// Google Maps SDK for iOS
//
// Copyright 2013 Google Inc.
//
// Usage of this SDK is subject to the Google Maps/Google Earth APIs Terms of
// Service: https://developers.google.com/maps/terms
//

#import <CoreLocation/CoreLocation.h>

#import <GoogleMapsBase/GMSCompatabilityMacros.h>

GMS_ASSUME_NONNULL_BEGIN

/**
* GMSCoordinateBounds represents a rectangular bounding box on the Earth's
* surface. GMSCoordinateBounds is immutable and can't be modified after
* construction.
*/
@interface GMSCoordinateBounds : NSObject

/** The North-East corner of these bounds. */
@property(nonatomic, readonly) CLLocationCoordinate2D northEast;

/** The South-West corner of these bounds. */
@property(nonatomic, readonly) CLLocationCoordinate2D southWest;

/**
* Returns NO if this bounds does not contain any points.
* For example, [[GMSCoordinateBounds alloc] init].valid == NO.
* When an invalid bounds is expanded with valid coordinates via
* includingCoordinate: or includingBounds:, the resulting bounds will be valid
* but contain only the new coordinates.
*/
@property(readonly, getter=isValid) BOOL valid;

/**
* Inits the northEast and southWest bounds corresponding
* to the rectangular region defined by the two corners.
*
* It is ambiguous whether the longitude of the box
* extends from |coord1| to |coord2| or vice-versa;
* the box is constructed as the smaller of the two variants, eliminating the
* ambiguity.
*/
- (id)initWithCoordinate:(CLLocationCoordinate2D)coord1
coordinate:(CLLocationCoordinate2D)coord2;

/**
* Returns a GMSCoordinateBounds representing
* the current bounds extended to include the passed-in coordinate.
* If the current bounds is invalid, the result is a valid bounds containing
* only |coordinate|.
*/
- (GMSCoordinateBounds *)includingCoordinate:(CLLocationCoordinate2D)coordinate;

/**
* Returns a GMSCoordinateBounds representing
* the current bounds extended to include the entire other bounds.
* If the current bounds is invalid, the result is a valid bounds equal
* to |other|.
*/
- (GMSCoordinateBounds *)includingBounds:(GMSCoordinateBounds *)other;

/**
* Returns YES if |coordinate| is contained within this bounds. This includes
* points that lie exactly on the edge of the bounds.
*/
- (BOOL)containsCoordinate:(CLLocationCoordinate2D)coordinate;

/**
* Returns YES if |other| overlaps with this bounds.
* Two bounds are overlapping if there is at least one coordinate point
* contained by both.
*/
- (BOOL)intersectsBounds:(GMSCoordinateBounds *)other;

@end

GMS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#import <GoogleMapsBase/GMSCompatabilityMacros.h>
#import <GoogleMapsBase/GMSCoordinateBounds.h>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
framework module GoogleMapsBase { umbrella header "GoogleMapsBase.h"
header "GMSCompatabilityMacros.h"
header "GMSCoordinateBounds.h"
export * module * { export * } }
1 change: 1 addition & 0 deletions Frameworks/GoogleMapsBase.framework/Versions/Current
1 change: 1 addition & 0 deletions Frameworks/GooglePlaces.framework/GooglePlaces
1 change: 1 addition & 0 deletions Frameworks/GooglePlaces.framework/Headers
1 change: 1 addition & 0 deletions Frameworks/GooglePlaces.framework/Modules
1 change: 1 addition & 0 deletions Frameworks/GooglePlaces.framework/Resources
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// GMSAddressComponent.h
// Google Places API for iOS
//
// Copyright 2016 Google Inc.
//
// Usage of this SDK is subject to the Google Maps/Google Earth APIs Terms of
// Service: https://developers.google.com/maps/terms
//

#if __has_feature(modules)
@import GoogleMapsBase;
#else
#import <GoogleMapsBase/GoogleMapsBase.h>
#endif

GMS_ASSUME_NONNULL_BEGIN

/**
* Represents a component of an address, e.g., street number, postcode, city, etc.
*/
@interface GMSAddressComponent : NSObject

/**
* Type of the address component. For a list of supported types, see
* https://developers.google.com/places/supported_types#table2. This string will be one of the
* constants defined in GMSPlaceTypes.h.
*/
@property(nonatomic, readonly, copy) NSString *type;

/** Name of the address component, e.g. "Sydney" */
@property(nonatomic, readonly, copy) NSString *name;

@end

GMS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
//
// GMSAutocompleteFetcher.h
// Google Places API for iOS
//
// Copyright 2016 Google Inc.
//
// Usage of this SDK is subject to the Google Maps/Google Earth APIs Terms of
// Service: https://developers.google.com/maps/terms
//

#if __has_feature(modules)
@import GoogleMapsBase;
#else
#import <GoogleMapsBase/GoogleMapsBase.h>
#endif
#if __has_feature(modules)
@import GoogleMapsBase;
#else
#import <GoogleMapsBase/GoogleMapsBase.h>
#endif
#import <GooglePlaces/GMSAutocompleteFilter.h>

@class GMSAutocompletePrediction;

GMS_ASSUME_NONNULL_BEGIN

/**
* Protocol for objects that can receive callbacks from GMSAutocompleteFetcher
*/
@protocol GMSAutocompleteFetcherDelegate <NSObject>

@required

/**
* Called when autocomplete predictions are available.
* @param predictions an array of GMSAutocompletePrediction objects.
*/
- (void)didAutocompleteWithPredictions:(GMS_NSArrayOf(GMSAutocompletePrediction *) *)predictions;

/**
* Called when an autocomplete request returns an error.
* @param error the error that was received.
*/
- (void)didFailAutocompleteWithError:(NSError *)error;

@end

/**
* GMSAutocompleteFetcher is a wrapper around the lower-level autocomplete APIs that encapsulates
* some of the complexity of requesting autocomplete predictions as the user is typing. Calling
* sourceTextHasChanged will generally result in the provided delegate being called with
* autocomplete predictions for the queried text, with the following provisos:
*
* - The fetcher may not necessarily request predictions on every call of sourceTextHasChanged if
* several requests are made within a short amount of time.
* - The delegate will only be called with prediction results if those predictions are for the
* text supplied in the most recent call to sourceTextHasChanged.
*/
@interface GMSAutocompleteFetcher : NSObject

/**
* Initialise the fetcher
* @param bounds The 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.
* @param filter The filter to apply to the results. This parameter may be nil.
*/
- (instancetype)initWithBounds:(GMSCoordinateBounds *GMS_NULLABLE_PTR)bounds
filter:(GMSAutocompleteFilter *GMS_NULLABLE_PTR)filter
NS_DESIGNATED_INITIALIZER;

/** Delegate to be notified with autocomplete prediction results. */
@property(nonatomic, weak) id<GMSAutocompleteFetcherDelegate> GMS_NULLABLE_PTR delegate;

/** Bounds used to bias the autocomplete search (can be nil). */
@property(nonatomic, strong) GMSCoordinateBounds *GMS_NULLABLE_PTR autocompleteBounds;

/** Filter to apply to autocomplete suggestions (can be nil). */
@property(nonatomic, strong) GMSAutocompleteFilter *GMS_NULLABLE_PTR autocompleteFilter;

/**
* Notify the fetcher that the source text to autocomplete has changed.
*
* This method should only be called from the main thread. Calling this method from another thread
* will result in undefined behavior. Calls to |GMSAutocompleteFetcherDelegate| methods will also be
* called on the main thread.
*
* This method is non-blocking.
* @param text The partial text to autocomplete.
*/
- (void)sourceTextHasChanged:(NSString *GMS_NULLABLE_PTR)text;

@end

GMS_ASSUME_NONNULL_END
Loading

0 comments on commit e888be8

Please sign in to comment.