-->

How can I evaluate the GPS signal strength? (iPhon

2019-03-16 10:51发布

问题:

I need a way of categorising the strength of the GPS signal. So far I have come across the horizontalAccuracy property of CLLocation (Class Reference).

To be more specific I need to create something like the following; the issue I'm having is filling in the if statements.

if (someLocation.horizontalAccuracy ...)
{
    // No Signal
}
else if (someLocation.horizontalAccuracy ...)
{
    // Poor Signal
}
else if (someLocation.horizontalAccuracy ...)
{
    // Average Signal
}
else if (someLocation.horizontalAccuracy ...)
{
    // Good Signal
}
else
{
    // Excellent Signal
}

Please can someone assist me in this?

回答1:

I've used figures like this in the past:

if (someLocation.horizontalAccuracy < 0)
{
    // No Signal
}
else if (someLocation.horizontalAccuracy > 163)
{
    // Poor Signal
}
else if (someLocation.horizontalAccuracy > 48)
{
    // Average Signal
}
else
{
    // Full Signal
}

but to be honest, it didn't really work very well for users. It would show as low accuracy, but when they looked at the maps app, it would have located them almost perfectly (albeit with a circle around them).

Rather than trying to define a level of accuracy, and if your app is map based, could you do what Maps does and show the horizontal accuracy as an circular overlay? Then the user can decide for themselves if it's accurate enough.