【问题标题】:How to get State specific result with Google autocomplete place api ios?如何使用 Google 自动完成位置 api ios 获得特定于州的结果?
【发布时间】:2017-07-12 06:51:11
【问题描述】:

我正在使用下面的代码来过滤国家数据,我得到了成功。我正在 Xcode 8.0 中开发 Swift 2.3。

        let autocompleteController = GMSAutocompleteViewController()
        autocompleteController.delegate = self

        let filter = GMSAutocompleteFilter()
        filter.type = .Address
        filter.country = "US"

        autocompleteController.autocompleteFilter = filter

        self.presentViewController(autocompleteController, animated: true, completion: nil)

我想要更多。

1) 我想过滤美国的特定州数据(如密歇根州),所以知道如何过滤它。我在最好的情况下遭受互联网的痛苦,但我无法获得它。

希望得到您的回复

【问题讨论】:

  • 嗨,您找到解决方案了吗?因为我必须做同样的事情。谢谢

标签: ios swift google-maps filter google-places-api


【解决方案1】:

获取该特定位置的地理位置(在您的情况下为密歇根州)并设置半径并在参数部分应用 strictBounds,它将仅显示该区域内的结果。

【讨论】:

  • 但是当该区域没有结果时,它会显示其他结果。如果您完全想限制您必须提供这些参数。
  • 我在“didAutocompleteWith place: GMSPlace”中更改了我的代码,我将“field.name”与状态“MI”或“Michigan”(字符串)进行比较。如果匹配,那就走得更远。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-10-19
  • 2018-04-13
  • 1970-01-01
相关资源
最近更新 更多