Closed technololy closed 5 years ago
We submit this code directly through the iOS API: https://developer.apple.com/documentation/corelocation/clgeocoder/1423509-geocodeaddressstring
There is not additional logic done by Essentials, just looks like iOS can't geocode your address :( Best to try/catch around it.
Thanks. also csme to that conclusion later on
@technololy, what I did was simply creating an extension method for this:
{
public static async Task<IEnumerable<Location>> SafeGetLocationsAsync(this Geocoding geocoding, string address)
{
try
{
var location = await geocoding.GetLocationsAsync(address);
return location;
}
catch (Exception)
{
//NOTE: because the iOS implementation is throwing an Exception, this helper method is implemented.
// For details check: https://github.com/xamarin/Essentials/issues/673
return new List<Location>();
}
}
}
Bug report best practices: Submitting Issues
Description
Description Geocoding(getting latitude/longitude from an address) works fine on Android but not in iOS (emulator and real device). The same address listed below returns, via geocoding, the latitude and longitude only on Android, not on iOS. I used the document here https://docs.microsoft.com/en-us/xamarin/essentials/. Note: Only particular to iOS
Steps to Reproduce
Steps to reproduce:
Expected Behavior
Expected Behavior Returns longitude and latitude of the entered address
Actual Behavior
Enters the catch which gives this error: {Foundation.NSErrorException: Error Domain=kCLErrorDomain Code=8 "(null)" at Xamarin.Essentials.Geocoding+d__4.MoveNext () [0x00075] in <80b8ae4e16374c93b74637a8a9a92836>:0
--- End of stack trace from previous location where exception was thrown
Basic Information
Screenshots
Reproduction Link
Reproduction Link here: https://github.com/technololy/TestingGeocoding