Closed GG-beyond closed 1 year ago
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)")
}
}
}
There's another way to do it
/// Start searching for query with provided options
/// - Parameters:
/// - coordinate: point Coordinate to resolve
/// - options: if no value provided Search Engine will use options from requestOptions field
final public func suggestions(for coordinate: CLLocationCoordinate2D, with options: MapboxSearch.AddressAutofill.Options? = nil, completion: @escaping (Result<[MapboxSearch.AddressAutofill.Suggestion], Error>) -> Void)
Why?
Hi @GG-beyond
Thank you for the report. The problem is caused by the default types, used in the AdressAutofill
request.
As a temporary workaround until the fix in the SDK is released, you could use reverse geocoding requests directly on SearchEngine, without the use of AdressAutofill
.
Hi @GG-beyond,
We've released a new version of SDK and there is a fix for the issue you reported. Please, check this out.
👍🏻
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")