【问题标题】:set GMSAutocompleteViewController to state specific only将 GMSAutocompleteViewController 设置为仅特定于状态
【发布时间】:2019-01-13 06:17:19
【问题描述】:

当我点击 GMSAutocompleteViewController 时,它应该只显示建议中的所有状态。我不想要这个领域的城市、国家或其他任何东西。那么这可能吗?

【问题讨论】:

  • 我不确定该州,但您可以按国家和地区进行过滤。
  • @MaheshDangar 我想要状态的结果...如果您对此有任何想法,请提供任何想法...
  • 你有没有找到解决方案,比如只有状态是过滤器?我有同样的要求谢谢

标签: ios swift google-maps autocomplete


【解决方案1】:

您不能直接过滤状态,Google Auto Complete API 提供了一些过滤器及其预定义的 ENUMS。

let autocompleteController = GMSAutocompleteViewController()
autocompleteController.delegate = self

// Set a filter to return only addresses.
let filter = GMSAutocompleteFilter()
filter.type = .address
autocompleteController.autocompleteFilter = filter

present(autocompleteController, animated: true, completion: nil)

GMSAutocompleteFilter.h:ENUMS 描述如下

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,
};

【讨论】:

  • 那我该怎么做状态过滤呢?这些是过滤器的类型。请添加状态过滤器的代码。谢谢
  • @YogeshPatel 嗨,我们如何从机构获取 postal_code ..?
猜你喜欢
  • 1970-01-01
  • 2020-08-20
  • 1970-01-01
  • 2019-03-24
  • 2020-04-21
  • 2018-12-09
  • 1970-01-01
  • 2020-11-02
  • 1970-01-01
相关资源
最近更新 更多