Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 将google autocomplete限制为仅限城市和国家/地区_Ios_Swift_Autocomplete - Fatal编程技术网

Ios 将google autocomplete限制为仅限城市和国家/地区

Ios 将google autocomplete限制为仅限城市和国家/地区,ios,swift,autocomplete,Ios,Swift,Autocomplete,我已经在我的应用程序中实现了谷歌自动完成功能。我想确保这些自动完成只为位置,行政区域和国家。不是道路或任何其他地方。我们能做到吗 typedef NS_ENUM(NSInteger, GMSPlacesAutocompleteTypeFilter) { /** * All results. */ kGMSPlacesAutocompleteTypeFilterNoFilter, /** * Geeocoding results, as opposed to busi

我已经在我的应用程序中实现了谷歌自动完成功能。我想确保这些自动完成只为位置,行政区域和国家。不是道路或任何其他地方。我们能做到吗

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 = GMSPlacesAutocompleteTypeFilter.City


您可以限制搜索结果

let filter = GMSAutocompleteFilter()
filter.type = .City
filter.country = "uk"
使用上述代码将结果限制在英国,只获取城市结果。

这对我来说很有效

let filter = GMSAutocompleteFilter()
filter.country = "uk|country:fr|country:us"

嗨,你能给我任何解决办法吗。我只想要州,不想要城市和国家。?谢谢你能给我任何解决办法吗。我只想要州,不想要城市和国家。?谢谢。@YogeshPatel我想各州都进入了
行政区域级别1
谢谢你的评论。是的,你说得对,但我怎么才能做到呢。请帮忙?