我想将 CLRegion(中心和半径)转换为两点(左上、右下)坐标集。
我看过这个答案,但不合适:将 MKCoordinateRegion 转换为 MKMapRect https://stackoverflow.com/questions/9270268/convert-mkcoordinateregion-to-mkmaprect
我之所以有 CLRegion 是因为它是正向地理定位的输出。
我需要两个纬度/经度点来查询数据库(因此不能使用 CLRegion containsCooperative)。
斯威夫特 3 示例
let searchRequest = MKLocalSearchRequest(completion: searchCompleter.results[indexPath.row])
let search = MKLocalSearch(request: searchRequest)
search.start { [weak self] response, error in
guard let region = response?.mapItems.first?.placemark.region as? CLCircularRegion else {
return
}
let mkregion = MKCoordinateRegionMakeWithDistance(region.center, region.radius*2, region.radius*2)
self?.mapView.setRegion(mkregion, animated: true)
self?.searchController.isActive = false
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)