使用 Google Places API for iOS 声明类型时出错



基本上我收到错误"类型'GMSPlacesAutocompleteTypeFilter'没有成员'食物',具有以下块:

let filter = GMSAutocompleteFilter()
filter.type = .food
autocompleteController.autocompleteFilter = filter

根据这里,应该识别类型食物。任何帮助将不胜感激。如果我缺少一些基本的东西,我深表歉意 - 我是 Swift 的新手。

您可以在"附近的搜索请求"中以及添加链接中显示的地点时使用此类型。

表 1:位置搜索和添加中支持的类型

您可以在位置的类型筛选器中使用以下值 搜索和添加地点时。

不像GMSPlacesAutocompleteTypeFilter,这些值可以在GMSPlacesAutocompleteTypeFilter类型中使用,我认为在您的情况下必须使用establishment

/**
* The type filters that may be applied to an autocomplete request to restrict results to different
* types.
*/
public enum GMSPlacesAutocompleteTypeFilter : Int {

/**
* All results.
*/
case noFilter
/**
* Geeocoding results, as opposed to business results.
*/
case geocode
/**
* Geocoding results with a precise address.
*/
case address
/**
* Business results.
*/
case establishment
/**
* Results that match the following types:
* "locality",
* "sublocality"
* "postal_code",
* "country",
* "administrative_area_level_1",
* "administrative_area_level_2"
*/
case region
/**
* Results that match the following types:
* "locality",
* "administrative_area_level_3"
*/
case city
}

希望这对你有帮助

最新更新