Fix an issue that the heading indicator does not rotate if Settings > Privacy > Location Services > System Services > Compass Calibration is off (#247)

* Fix an issue that the heading indicator does not rotate if Settings > Privacy > Location Services > System Services > Compass Calibration is off.

* Update CHANGELOG.md

Co-authored-by: Nishant Karajgikar <nishant-karajgikar@users.noreply.github.com>
Co-authored-by: Minh Nguyễn <mxn@1ec5.org>
This commit is contained in:
ystsoi
2020-04-25 05:38:23 +08:00
committed by GitHub
parent f3da2d7053
commit 47f1d7bb94
3 changed files with 5 additions and 3 deletions

View File

@@ -267,9 +267,10 @@ const CGFloat MGLUserLocationHeadingUpdateThreshold = 0.01;
_oldHeadingAccuracy = headingAccuracy;
}
if (self.userLocation.heading.trueHeading >= 0)
CLLocationDirection headingDirection = (self.userLocation.heading.trueHeading >= 0 ? self.userLocation.heading.trueHeading : self.userLocation.heading.magneticHeading);
if (headingDirection >= 0)
{
CGFloat rotation = -MGLRadiansFromDegrees(self.mapView.direction - self.userLocation.heading.trueHeading);
CGFloat rotation = -MGLRadiansFromDegrees(self.mapView.direction - headingDirection);
// Don't rotate if the change is imperceptible.
if (fabs(rotation) > MGLUserLocationHeadingUpdateThreshold)

View File

@@ -91,7 +91,7 @@ NS_ASSUME_NONNULL_END
- (void)setHeading:(CLHeading *)newHeading
{
if (newHeading.trueHeading != _heading.trueHeading)
if (newHeading.trueHeading != _heading.trueHeading || newHeading.magneticHeading != _heading.magneticHeading)
{
[self willChangeValueForKey:@"heading"];
_heading = newHeading;