ios – CLGeocoder错误. GEOErrorDomain代码= -3

ios – CLGeocoder错误. GEOErrorDomain代码= -3,第1张

概述当我尝试使用反向地理编码时,出现此错误消息. Geocode error: Error Domain=GEOErrorDomain Code=-3 “(null)” 我的代码如下: import CoreLocationgeocoder.reverseGeocodeLocation(location) { (placemarks, error) in if let placemarks 当我尝试使用反向地理编码时,出现此错误消息.

Geocode error: Error Domain=GEOErrorDomain Code=-3 “(null)”

我的代码如下:

@R_301_5565@ CoreLocationgeocoder.reverseGeocodeLocation(location) { (placemarks,error) in    if let placemarks = placemarks {        reverseGeocodeLocations[hash] = placemarks    }    callback(placemarks,error)}

这只是不时工作,我每秒多次请求reverseGeocode.所以我猜这个错误信息与请求的限制有什么关系?
有没有关于apple的地理编码请求的文档?
谢谢你提前.

更新

这是我的整个代码请求

@R_301_5565@ CoreLocationfileprivate 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] {            callback(value,nil)        } else {            reverseGeocodeQueue.async {                guard let value = reverseGeocodeLocations[hash] else {                    geocoder.reverseGeocodeLocation(location) { (placemarks,error) in                        if let placemarks = placemarks {                            reverseGeocodeLocations[hash] = placemarks                        }                        callback(placemarks,error)                    }                    return                }                callback(value,nil)            }        }    }    let priority: UInt    let location: CLLocation    let handler : ([CLPlacemark]?,Error?)->VoID    private init (location: CLLocation,handler: @escaPing ([CLPlacemark]?,Error?)->VoID) {        ReverseGeocodeRequest.nextPriority += 1        self.priority = ReverseGeocodeRequest.nextPriority        self.location = location        self.handler  = handler    }}extension ReverseGeocodeRequest: Comparable {    static fileprivate func < (lhs: ReverseGeocodeRequest,rhs: ReverseGeocodeRequest) -> Bool {        return lhs.priority < rhs.priority    }    static fileprivate func == (lhs: ReverseGeocodeRequest,rhs: ReverseGeocodeRequest) -> Bool {        return lhs.priority == rhs.priority    }}extension CLLocation {    func reverseGeocodeLocation(callback: @escaPing ([CLPlacemark]?,Error?)->VoID) {        ReverseGeocodeRequest.request(location: self,callback: callback)    }    func getPlacename(callback: @escaPing (Error?,String?)->VoID) {        self.reverseGeocodeLocation { (placemarks,error) in            guard let placemarks = placemarks,error == nil else {                callback(error,nil)                return            }            guard let placemark = placemarks.first else {                callback(nil,"MysterIoUs place")                return            }            if let areaOfInterest = placemark.areasOfInterest?.first {                callback(nil,areaOfInterest)            } else if let locality = placemark.locality {                callback(nil,locality)            } else {                callback(nil,"On the Earth")            }        }    }}
解决方法 在搜索到答案后,它在Apples文档中! :/

https://developer.apple.com/reference/corelocation/clgeocoder/1423621-reversegeocodelocation

GeoCoding requests are rate-limited for each app,so making too many requests in a short period of time may cause some of the requests to fail. When the maximum rate is exceeded,the geocoder passes an error object with the value network to your completion handler.

在完成处理程序中检查错误代码时,确实是网络错误:2

希望这有助于某人!

总结

以上是内存溢出为你收集整理的ios – CLGeocoder错误. GEOErrorDomain代码= -3全部内容,希望文章能够帮你解决ios – CLGeocoder错误. GEOErrorDomain代码= -3所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1107686.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-28
下一篇2022-05-28

发表评论

登录后才能评论

评论列表(0条)

    保存