I have recently just finished my own service for fetching the location of the device on iOS - and I have encountered a strange value in the accuracy constants that can be set to the CLLocationManager
instance. They are: https://developer.apple.com/documentation/corelocation/kcllocationaccuracybestfornavigation
According to the xamarin docs: https://docs.microsoft.com/en-us/xamarin/ios/app-fundamentals/backgrounding/ios-backgrounding-walkthroughs/location-walkthrough
the value which is a double is in meters. So it can be set to one meter.
Xamarin Essentials uses these contants: https://github.com/xamarin/Essentials/blob/master/Xamarin.Essentials/Geolocation/GeolocationRequest.ios.cs
Using the best constant: AccurracyBestForNavigation - it prints out -2
.
I found it a bit confusing. Is it an error or can the accuracy somehow be set to a negative amount of meters?
If you set its value to a fixed constant float it means you want location service to offer this accuracy.
If you use this predefined constant location service will try its best to offer the best navigation coordinates. Maybe larger than 1 meter or less than it(50 cm...) depending on the environment aside.
It obviously doesn't mean -2 meter. Some negative amounts have special meanings. i.e.
We will often set the number of lines of UILabel to -1 to fit the content. However, it doesn't mean we want the lines to be -1.
Answers
CLLocation.AccurracyBestForNavigation
is a predefined property ofCLLocation
. It could have some special internal usage or special meaning. I haven't tried to print out its specific value and I think there's no need to.Normally, we consumed its property directly.
Question is if I get better accuracy with 1 meter as proposed in the example in the Microsoft docs - or if I will getter better accuracy using the constant
If you set its value to a fixed constant float it means you want location service to offer this accuracy.
If you use this predefined constant location service will try its best to offer the best navigation coordinates. Maybe larger than 1 meter or less than it(50 cm...) depending on the environment aside.
It obviously doesn't mean -2 meter. Some negative amounts have special meanings. i.e.
We will often set the number of lines of UILabel to -1 to fit the content. However, it doesn't mean we want the lines to be -1.