Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
naouaro authored Dec 25, 2016
1 parent 9279ccd commit ffd2495
Show file tree
Hide file tree
Showing 76 changed files with 1,658 additions and 0 deletions.
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/ios-api/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
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
//
// GMSAutocompleteFilter.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

/**
* The type filters that may be applied to an autocomplete request to restrict results to different
* types.
*/
typedef NS_ENUM(NSInteger, GMSPlacesAutocompleteTypeFilter) {
/**
* All results.
*/
kGMSPlacesAutocompleteTypeFilterNoFilter,
/**
* Geeocoding results, as opposed to business results.
*/
kGMSPlacesAutocompleteTypeFilterGeocode,
/**
* Geocoding results with a precise address.
*/
kGMSPlacesAutocompleteTypeFilterAddress,
/**
* Business results.
*/
kGMSPlacesAutocompleteTypeFilterEstablishment,
/**
* Results that match the following types:
* "locality",
* "sublocality"
* "postal_code",
* "country",
* "administrative_area_level_1",
* "administrative_area_level_2"
*/
kGMSPlacesAutocompleteTypeFilterRegion,
/**
* Results that match the following types:
* "locality",
* "administrative_area_level_3"
*/
kGMSPlacesAutocompleteTypeFilterCity,
};

/**
* This class represents a set of restrictions that may be applied to autocomplete requests. This
* allows customization of autocomplete suggestions to only those places that are of interest.
*/
@interface GMSAutocompleteFilter : NSObject

/**
* The type filter applied to an autocomplete request to restrict results to different types.
* Default value is kGMSPlacesAutocompleteTypeFilterNoFilter.
*/
@property(nonatomic, assign) GMSPlacesAutocompleteTypeFilter type;

/**
* The country to restrict results to. This should be a ISO 3166-1 Alpha-2 country code (case
* insensitive). If nil, no country filtering will take place.
*/
@property(nonatomic, copy) NSString *GMS_NULLABLE_PTR country;

@end

GMS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// GMSAutocompleteMatchFragment.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

/**
* This class represents a matched fragment of a string. This is a contiguous range of characters
* in a string, suitable for highlighting in an autocompletion UI.
*/
@interface GMSAutocompleteMatchFragment : NSObject

/**
* The offset of the matched fragment. This is an index into a string. The character at this index
* is the first matched character.
*/
@property(nonatomic, readonly) NSUInteger offset;

/**
* The length of the matched fragment.
*/
@property(nonatomic, readonly) NSUInteger length;

@end

GMS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
//
// GMSAutocompletePrediction.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

/*
* Attribute name for match fragments in |GMSAutocompletePrediction| attributedFullText.
*/
extern NSString *const kGMSAutocompleteMatchAttribute;

/**
* This class represents a prediction of a full query based on a partially typed string.
*/
@interface GMSAutocompletePrediction : NSObject

/**
* The full description of the prediction as a NSAttributedString. E.g., "Sydney Opera House,
* Sydney, New South Wales, Australia".
*
* Every text range that matches the user input has a |kGMSAutocompleteMatchAttribute|. For
* example, you can make every match bold using enumerateAttribute:
* <pre>
* UIFont *regularFont = [UIFont systemFontOfSize:[UIFont labelFontSize]];
* UIFont *boldFont = [UIFont boldSystemFontOfSize:[UIFont labelFontSize]];
*
* NSMutableAttributedString *bolded = [prediction.attributedFullText mutableCopy];
* [bolded enumerateAttribute:kGMSAutocompleteMatchAttribute
* inRange:NSMakeRange(0, bolded.length)
* options:0
* usingBlock:^(id value, NSRange range, BOOL *stop) {
* UIFont *font = (value == nil) ? regularFont : boldFont;
* [bolded addAttribute:NSFontAttributeName value:font range:range];
* }];
*
* label.attributedText = bolded;
* </pre>
*/
@property(nonatomic, copy, readonly) NSAttributedString *attributedFullText;

/**
* The main text of a prediction as a NSAttributedString, usually the name of the place.
* E.g. "Sydney Opera House".
*
* Text ranges that match user input are have a |kGMSAutocompleteMatchAttribute|,
* like |attributedFullText|.
*/
@property(nonatomic, copy, readonly) NSAttributedString *attributedPrimaryText;

/**
* The secondary text of a prediction as a NSAttributedString, usually the location of the place.
* E.g. "Sydney, New South Wales, Australia".
*
* Text ranges that match user input are have a |kGMSAutocompleteMatchAttribute|, like
* |attributedFullText|.
*
* May be nil.
*/
@property(nonatomic, copy, readonly) NSAttributedString *GMS_NULLABLE_PTR attributedSecondaryText;

/**
* An optional property representing the place ID of the prediction, suitable for use in a place
* details request.
*/
@property(nonatomic, copy, readonly) NSString *GMS_NULLABLE_PTR placeID;

/**
* The types of this autocomplete result. Types are NSStrings, valid values are any types
* documented at <https://developers.google.com/places/ios-api/supported_types>.
*/
@property(nonatomic, copy, readonly) GMS_NSArrayOf(NSString *) *types;

@end

GMS_ASSUME_NONNULL_END
Loading

0 comments on commit ffd2495

Please sign in to comment.