![](/img/trans.png)
[英]How to get only India city names in Google Autocomplete iOS?
[英]Limit google autocomplete to City and Country only iOS Swift
我已經在我的應用中實現了 google AutoComplete 功能。 我想確保這些自動完成僅適用於位置、行政區域和國家。 不是道路或任何其他地方。 我們能做到嗎?
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,
};
這可以通過編輯這個頭文件來實現嗎? 但我嘗試刪除其中一些。 但仍然工作相同。
您可以限制搜索結果
let filter = GMSAutocompleteFilter()
filter.type = .City
filter.country = "uk"
使用上面的代碼將結果限制為英國並只獲得城市結果。
搜索了一段時間后。 我找到了解決方案。
let filter = GMSAutocompleteFilter()
filter.type = GMSPlacesAutocompleteTypeFilter.City
這對我有用
let filter = GMSAutocompleteFilter()
filter.country = "uk|country:fr|country:us"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.