Atlas
为 Google Places 搜索和地理编码库提供替代方案,以使用我们的自定义端点。
iOS SearchPlaces
使用 API 进行 iOS 地点搜索
- 语言:Swift 5
- 设备:iPhone,iPad
- 框架
- UIKit
将 Git 仓库项目添加到构建中
步骤 1
实现 SearchHelper 类
- 使用此行调用来完成处理程序并通过将输入字符串传递到 inputText 来搜索地点
@objc func textFieldDidChange(_ textField: UITextField) {
SearchHelper.shared.getLocation(inputText: textField.text, completion: { predictions in
// predictions are [[String: AnyObject]] values
// Use your code with predictions
}
步骤 2。
在转换为经纬度地理编码时需要传递的地点 ID
- 使用此行调用完成处理程序并传递选择的 Indexpath.row - placeid
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
selectedLocation(placeid: [indexPath.row].PlaceId, completion: { location in
// location are [String: AnyObject] values
// Use your code with location to get Latitude and Longitute
}