Ios 如果位置地址为零,如何通过反向定位获得附近的地址?

Ios 如果位置地址为零,如何通过反向定位获得附近的地址?,ios,iphone,swift,reversegeocodelocation,Ios,Iphone,Swift,Reversegeocodelocation,我试图通过reverseGeocodeLocation获取位置的地址,但有时它返回nil address,如果reverseGeocodeLocation为任何特定位置返回nil address,我想要的是获取附近的地址 public class func getAddressFrom(location: CLLocation, completion:@escaping ((String?) -> Void)) { let geocoder = CLGeocoder()

我试图通过reverseGeocodeLocation获取位置的地址,但有时它返回nil address,如果reverseGeocodeLocation为任何特定位置返回nil address,我想要的是获取附近的地址

public class func getAddressFrom(location: CLLocation, completion:@escaping ((String?) -> Void)) {
        let geocoder = CLGeocoder()
        geocoder.reverseGeocodeLocation(location) { (placemarks, error) in
            if let placemark = placemarks?.first,
                let subThoroughfare = placemark.subThoroughfare,
                let thoroughfare = placemark.thoroughfare,
                let locality = placemark.locality,
                let administrativeArea = placemark.administrativeArea {
                let address = subThoroughfare + " " + thoroughfare + ", " + locality + " " + administrativeArea

                //placemark.addressDictionary

                return completion(address)

            }
            completion(nil)
        }
    }

您可能达到了地理编码器的极限

摘自:

每个应用程序的地理编码请求都有速率限制,因此在短时间内发出过多请求可能会导致某些请求失败。当超过最大速率时,地理编码器将带有值网络的错误对象传递给完成处理程序


我没有收到错误,只是位置没有地址,我只是在位置发生变化时请求ReverseGeoDelocation