Google reverseGeocodeLocation很慢

时间:2018-12-12 13:20:56

标签: swift delay reversegeocodelocation

我已经使用这种方法从地址中解码地址。

func getAdressName(coords: CLLocation) {

CLGeocoder().reverseGeocodeLocation(location) { (placemark, error) in
        if error != nil {
            print("Hay un error")
        } else {

            let place = placemark! as [CLPlacemark]
            if place.count > 0 {
                let place = placemark![0]
                var adressString : String = ""
                if place.thoroughfare != nil {
                    adressString = adressString + place.thoroughfare! + ", "
                }
                if place.subThoroughfare != nil {
                    adressString = adressString + place.subThoroughfare! + "\n"
                }
                if place.locality != nil {
                    adressString = adressString + place.locality! + " - "
                }
                if place.postalCode != nil {
                    adressString = adressString + place.postalCode! + "\n"
                }
                if place.subAdministrativeArea != nil {
                    adressString = adressString + place.subAdministrativeArea! + " - "
                }
                if place.country != nil {
                    adressString = adressString + place.country!
                }

                self.lblPlace.text = adressString
            }
        }
    }

}

但是我发现这有5秒的延迟。有什么办法可以紧固吗?

0 个答案:

没有答案