Название здания с использованием текущего местоположения - PullRequest
0 голосов
/ 31 мая 2019

Я пытаюсь получить номер дома, используя CLLocationManagerDelegate и MKMapViewDelegate, но это не сработало.Используя это, я получаю Sub-locality area и sub административную проезд и проезд, но не получаю название здания.

Пожалуйста, помогите, как получить название здания

Я уже пытался использовать CLLocationManagerDelegate метод reversegeocoder и CLLocationManagerDelegate.

 CLGeocoder().reverseGeocodeLocation(location){ (placemark, error)   in
        let place = placemark?[0]

 print(placemark?[0].addressDictionary?[0])

        let subloc = place?.subLocality
        let city = place?.locality
        print("\(subloc!),\(city!),\(place?.administrativeArea)")
        print(place?.areasOfInterest?.count)
        if let subLocal = place?.subLocality, let cityCustom = place?.locality
       {
         self.locationname.text = ("\(subLocal),\(cityCustom)")
        self.locationname.text = (placemark?[0].addressDictionary?[0]) as? String
         self.address = self.locationname.text ?? ""
        print(placemark?[0].addressDictionary?[0]) as? String
        if let marks = placemark, marks.count > 0 {
            let placemark = marks[0]
            let postalAddress = placemark.addressDictionary

            if let address = postalAddress?.first {

                print("\(address)")
            }
            if let State = placemark.addressDictionary?["State"]{

                print("\(State)")
            }
            if let Street = placemark.addressDictionary?["Street"]{

                print("\(Street)")
            }
            if let Name = placemark.addressDictionary?["Name"]{

                print("\(Name)")
            }
            if let Thoroughfare = placemark.addressDictionary?["Thoroughfare"]{

                print("\(Thoroughfare)")
            }
            if let subThoroughfare = placemark.addressDictionary?["SubThoroughfare"]{

                print("\(subThoroughfare)")
            }
            if let FormattedAddressLines = placemark.addressDictionary?["FormattedAddressLines"]{

                print("\(FormattedAddressLines)")
                self.locationname.text = (FormattedAddressLines as AnyObject).componentsJoined(by: ",") as? String
                self.address = self.locationname.text ?? ""
                 self.locationname.numberOfLines = 2
                 self.locationname.sizeToFit()
                self.locationname.textAlignment = .center
            }
        }

     }
    else
     {
         self.alertbox(title1: UrlSheet.UrlName.msgTitle, message1: "Location service is disabled on your phone at the moment. Please enable the same before marking the attendance.")
      }
    self.mapviews.isUserInteractionEnabled = false
    manager.stopUpdatingLocation()
   }

Ожидаемый результат:

DLf-Tower A, Jasola Distric Center,New Delhi
Actual Result:  Jasola Distric Center,New Delhi

1 Ответ

0 голосов
/ 31 мая 2019

Посещение: https://developer.apple.com/documentation/corelocation/clplacemark Для всех поддерживаемых меток Apple

...