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

时间:2017-07-25 03:55:52

标签: ios swift xcode google-maps-api-3 google-places-api

基本上我得到错误“Type'GMSPlacesAutocompleteTypeFilter'没有成员'food',带有以下块:

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

根据here,应该识别食物类型。任何帮助,将不胜感激。如果我缺少基本的东西,我也很抱歉 - 我是Swift的新手。

1 个答案:

答案 0 :(得分:0)

您可以在附近的搜索请求中使用此类型,并在链接中显示地点

  

表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
}

希望这有助于你