【发布时间】:2017-05-15 11:55:45
【问题描述】:
我使用 GMSAutocompleteViewController 是为了让用户搜索地址。 用户选择建议后,如何从 GMSAutocompleteViewController 获取地址详细信息? 我正在使用
func viewController(_ viewController: GMSAutocompleteViewController, didAutocompleteWith place: GMSPlace) {
获取 UI 控制器的结果。然后我进行反向地理编码以获得 GMSAddress。代码是这样的:
GMSGeocoder().reverseGeocodeCoordinate(place.coordinate, completionHandler: { (response:GMSReverseGeocodeResponse?, err:Error?) in
...
let firstAddr:GMSAddress = (response?.firstResult())!
我能够从 firstAddr 获取城市、国家/地区。但是我需要街道和街道号码的单独结果,以防万一。我尝试使用 thoroughfare 和 addressLine1, addressLine2 但没有结果,它们返回街道和街道号码的组合,我没有模式来拆分它。
获取方式方便吗?
【问题讨论】:
标签: ios swift google-maps geocoding reverse-geocoding