GMSAutocomplete过滤器中缺少"Country"属性 来自谷歌地图 iOS SDK



在我的iOS项目中,我使用谷歌地图SDK获取自动完整地址。因此,我想将我的结果限制在特定的国家/地区。根据谷歌文档,我必须使用GMSAutocompleteFilter类的"country"属性。在谷歌文档中,它在谷歌地图SDK中有"country"属性actual.h文件,但它没有。

文档链接: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

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

最新更新