0
func getLocationAddress() {
        let centerCoordinate = CLLocationCoordinate2D(latitude: -34.005676, longitude: 138.795836)//mapView.centerCoordinate
        addressAutofill.suggestions(for: centerCoordinate) { [weak self] result in
            guard let self = self else { return }
            switch result {
            case .success(let suggestions):
                if let first = suggestions.first {
                    self.addressAutofill.select(suggestion: first) { [weak self] result in
                        guard let self = self else { return }
                        if case .success = result {
                        } else {
                        }
                    }
                }
            case .failure(let error):
                print("error = \(error)")
            }
        }
    }
error = generic(code: 422, domain: "MapboxCoreSearchErrorDomain", message: "Type "countryregionpostcodedistrictplacelocalityneighborhoodaddressstreetpoi" is not a known type. Must be one of: country, region, place, district, locality, postcode, neighborhood, address, poi, poi.landmark")

mapbox-search-ios version: 1.0.0-rc.4

try:
1、The official demo has the same problem
2、‘options’ 、‘countries’ 、‘language’ has the same problem

beyond峰
  • 1
  • 2

1 Answers1

0
let engine = SearchEngine()
func getLocationAddress() {
    engine.reverseGeocoding(options: ReverseGeocodingOptions(point: CLLocationCoordinate2D(latitude: -35.490594, longitude: 138.795836),types: [.address],languages: [])) { [weak self] result in
        guard let self = self else { return}
        switch result {
        case .success(let suggestions):
            print("suggestions = \(suggestions)")
            if let first = suggestions.first {
                print("first = \(String(describing: first.address))")
            }
        case .failure(let error):
            print("error = \(error)")
        }
    }
}
beyond峰
  • 1
  • 2
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 09 '23 at 05:40