ios - 如何从 CoreLocations geocodeAddressString 获取更多结果?

标签 ios swift core-location

我有一个应用程序,允许用户输入一些地址,然后我想基本上提供他们可能引用的可能地址列表,以便我可以以 MapKit 可读形式使用它。

我目前的做法是这样的:

extension ViewController: UITextFieldDelegate{

    func textFieldDidEndEditing(_ textField: UITextField) {
        CLGeocoder().geocodeAddressString(textField.text!, completionHandler: {(placemarks: [CLPlacemark]?, error: Error?) -> Void in
            if let placemarks = placemarks{
                //send placemarks to table view
                //however, placemarks only contains one element  
                //(even when textfield contains very generic text)
            } else{ }   
        })
    }
}

有人知道如何获得更多结果吗?使用 Apple 的 map 应用程序,只需输入 4 个数字即可加载 15 个结果,我怎样才能让我的应用程序显示这么多结果? Apple 是否使用 coreLocation 以外的其他方式来显示可能的位置?

最佳答案

编辑:我认为Google Places API iOS 版应该可以帮助您获得所需的内容。我不相信 Apple 有等效的 API(除非您想要像 MKLocalSearchRequest 这样的简单语言搜索)。

关于ios - 如何从 CoreLocations geocodeAddressString 获取更多结果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44090896/

相关文章:

ios - Jenkins + TestFlight + GitHub

ios - 通过点击单元格内的图像从 UITableViewCell 切换

json - 使用 SwiftyJSON 解析 JSON 时出现问题

ios - 应用程序终止时如何获取用户的当前位置

ios - 表格 View 不适用于自定义单元格

ios - 如何检测父类(super class)的实例是否是子类?

swift - 在 Swift 中正确使用 defer

ios - 如何手动将 PFFile 从 PFQueryTableViewController 转移到另一个 ViewController?

ios - locationManager 没有更新 Location

iphone - 使用 CoreLocation 防止零星坐标