当我尝试使用反向地理编码时,出现此错误消息.
地理编码错误:错误域= GEOErrorDomain代码= -3"(null)"
我的代码如下:
import CoreLocation
geocoder.reverseGeocodeLocation(location) { (placemarks, error) in
if let placemarks = placemarks {
reverseGeocodeLocations[hash] = placemarks
}
callback(placemarks, error)
}
Run Code Online (Sandbox Code Playgroud)
这只是不时工作,我每秒多次请求reverseGeocode.所以我猜这个错误信息与请求的限制有什么关系?有没有关于apple的地理编码请求的文档?谢谢你提前.
更新
这是我的整个代码请求
import CoreLocation
fileprivate struct ReverseGeocodeRequest {
private static let geocoder = CLGeocoder()
private static var reverseGeocodeLocations = [Int: [CLPlacemark]]()
private static let reverseGeocodeQueue = DispatchQueue(label: "ReverseGeocodeRequest.reverseGeocodeQueue")
private static var nextPriority: UInt = 0
fileprivate static func request(location: CLLocation, callback: @escaping ([CLPlacemark]?, Error?)->Void) {
let hash = location.hash
if let value = reverseGeocodeLocations[hash] …Run Code Online (Sandbox Code Playgroud)