DanijelHuis / HDAugmentedReality

Augmented Reality component for iOS, written in Swift.
MIT License
480 stars 97 forks source link

trueHeading not defined on iPhone 7 Plus #29

Closed mets1985 closed 7 years ago

mets1985 commented 7 years ago

Hi,

I found that trueHeading is always -1 on iPhone 7 Plus, while the magneticHeader is valorized correctly.

I solved changing the didUpdateHeading method:

` open func locationManager(_ manager: CLLocationManager, didUpdateHeading newHeading: CLHeading) {

    if newHeading.trueHeading != -1
    {
        self.heading = fmod(newHeading.trueHeading, 360.0)
    }
    else
    {
        self.heading = fmod(newHeading.magneticHeading, 360.0)
    }

}`

ccreonopoulos commented 7 years ago

I am getting the same issue on iPhone SE. I believe this could be a good enhancement.

DanijelHuis commented 7 years ago

Maybe location services are not enabled on your device? As I understand location is needed to determine trueHeading.

If location updates are not enabled, the location manager returns only the magnetic heading value.

Also it might be because of external magnetic fields so the compass needs calibration, If you have the time you can try implementing locationManagerShouldDisplayHeadingCalibration(_:) and return true.

I will implement your fix in version 2.0.0 probably, thanks!