当我单击GMSAutocompleteViewController时,它应该仅显示建议中的所有状态。我不想要这个领域中的城市,国家或其他任何地方。那有可能吗?
答案 0 :(得分:0)
您不能直接过滤状态,Google Auto Complete API提供了一些过滤器及其预定义的ENUMS。
let autocompleteController = GMSAutocompleteViewController()
autocompleteController.delegate = self
// Set a filter to return only addresses.
let filter = GMSAutocompleteFilter()
filter.type = .address
autocompleteController.autocompleteFilter = filter
present(autocompleteController, animated: true, completion: nil)
GMSAutocompleteFilter.h :下面的ENUMS描述
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,
};