AI-generated Key Takeaways
-
GMSAutocompleteFiltercustomizes autocomplete suggestions by restricting results based on criteria like place types, countries, and location. -
It provides properties to filter by place types (using
types), countries (usingcountries), origin location (origin), and location bias (locationBias). -
Deprecated properties
typeandcountryare replaced bytypesandcountriesrespectively, allowing for multiple selections. -
Developers can further refine results using
locationRestriction,regionCode, andinputOffsetto control the scope and format of suggestions. -
This class is essential for tailoring autocomplete results to specific user needs and geographic contexts within map-based applications.
GMSAutocompleteFilter
@interface GMSAutocompleteFilter : NSObjectThis 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.
-
Deprecated
typeproperty is deprecated in favor oftypes.DEPRECATED. The type filter applied to an autocomplete request to restrict results to different types. Default value is kGMSPlacesAutocompleteTypeFilterNoFilter.
NOTE: Ignored if the “types” property is set.
Declaration
Swift
var type: GMSPlacesAutocompleteTypeFilter { get set }Objective-C
@property (nonatomic) GMSPlacesAutocompleteTypeFilter type; -
The filter applied to an autocomplete request to restrict results using up to 5 different place types.
NOTE: This API can take an array of up to 5 entries. If you are using
GMSAutocompleteRequest, this API can take types from table_A. Otherwise, take data from table_1 or table_2, but only a single entry in table_3. Default value is null, which means no filters specified. Overrides the deprecated “type” property if this is set.Declaration
Swift
var types: [String]? { get set }Objective-C
@property (nonatomic, nullable) NSArray<NSString *> *types; -
Deprecated
countryproperty is deprecated in favor ofcountries.DEPRECATED. 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.
NOTE: Ignored if the “countries” property is set.
Declaration
Swift
var country: String? { get set }Objective-C
@property (nonatomic, copy, nullable) NSString *country; -
The countries to restrict results to. This should be a ISO 3166-1 Alpha-2 country code (case insensitive). Supports up to 5 countries to filter. If nil, no country filtering will take place.
NOTE: Overrides the deprecated “country” property if that is set.
Declaration
Swift
var countries: [String]? { get set }Objective-C
@property (nonatomic, copy, nullable) NSArray<NSString *> *countries; -
The straight line distance origin location for measuring the straight line distance between the origin location and autocomplete predictions.
Declaration
Swift
var origin: CLLocation? { get set }Objective-C
@property (nonatomic, nullable) CLLocation *origin; -
The optional location bias to prefer place results near the location.
Declaration
Swift
var locationBias: (any GMSPlaceLocationBias)? { get set }Objective-C
@property (nonatomic, nullable) id<GMSPlaceLocationBias> locationBias; -
The optional location restriction to limit place results.
Declaration
Swift
var locationRestriction: (any GMSPlaceLocationRestriction)? { get set }Objective-C
@property (nonatomic, nullable) id<GMSPlaceLocationRestriction> locationRestriction; -
regionCode affects address formatting, result ranking, and potentially hiding or showing certain results.
Declaration
Swift
var regionCode: String? { get set }Objective-C
@property (nonatomic, nullable) NSString *regionCode; -
inputOffset is the character offset of the input that indicates where the
- completions may start from.
Declaration
Swift
var inputOffset: Int32 { get set }Objective-C
@property (nonatomic) int32_t inputOffset; -
Whether pure service area businesses should be included in the results.
A pure service area business is a business that visits or delivers to customers directly, but does not serve customers at their business address. For example, businesses like cleaning services or plumbers. Those businesses do not have a physical address or location on Google Maps. Places will not return fields including
location,plusCode, and other location related fields for these businesses.Default value is false.
Declaration
Swift
var shouldIncludePureServiceAreaBusinesses: Bool { get set }Objective-C
@property (nonatomic) BOOL shouldIncludePureServiceAreaBusinesses;