"Country" 属性 Google 地图 iOS SDK 中的 GMSAutocompleteFilter 缺失

"Country" property missing in GMSAutocompleteFilter from Google maps iOS SDK

在我的 iOS 项目中,我使用 Google 地图 SDK 来获取自动完成地址。因此,我想将我的结果限制在特定国家/地区根据 Google 文档,我必须使用 "country" 属性 of GMSAutocompleteFilter class .在 Google 文档中它有 "country" 属性 在 Google maps SDK 中它没有的实际 .h 文件。

文档 link:https://developers.google.com/maps/documentation/ios-sdk/reference/interface_g_m_s_autocomplete_filter.html#properties

GMSAutocompleteFilter.h 文件:

//
//  GMSAutocompleteFilter.h
//  Google Maps SDK for iOS
//
//  Copyright 2014 Google Inc.
//
//  Usage of this SDK is subject to the Google Maps/Google Earth APIs Terms of
//  Service: https://developers.google.com/maps/terms
//

/**
 * The type filters that may be applied to an autocomplete request to restrict results to different
 * types.
 */
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,
};

/**
 * This class represents a set of restrictions that may be applied to autocomplete requests. This
 * allows customization of autocomplete suggestions to only those places that are of interest.
 */
@interface GMSAutocompleteFilter : NSObject

/**
 * The type filter applied to an autocomplete request to restrict results to different types.
 * Default value is kGMSPlacesAutocompleteTypeFilterNoFilter.
 */
@property(nonatomic, assign) GMSPlacesAutocompleteTypeFilter type;

@end

任何帮助将不胜感激。

您可能需要更新 Google 地图 SDK。 https://cocoapods.org/?q=google

终于解决了这个问题,承认这是由于 Google 地图 iOS SDK 的旧版本造成的。我一直在获取 Google SDK,但没有在 podfile 中指定任何版本号,它给了我 1.10 版本。因此我更新了 Google SDK pods 版本 1.12.3 然后我在 GMSAutocompleteFilter class.[=10 中有 "country" 字段=]