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

@@ -41,6 +41,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT
* Added the `MGLMapView.minimumPitch` and `MGLMapView.maximumPitch` properties to further limit how much the user or your code can tilt the map. ([#208](https://github.com/mapbox/mapbox-gl-native-ios/pull/208))
* Fixed a crash while quitting the application after adding an annotation to `MGLMapView`. ([#252](https://github.com/mapbox/mapbox-gl-native-ios/pull/252))
* Fixed an issue where the user location annotation view’s heading indicator did not rotate if Compass Calibration was disabled in the device’s Location Services settings. ([#247](https://github.com/mapbox/mapbox-gl-native-ios/pull/247))
* Improved performance when continuously animating a tilted map. ([#16287](https://github.com/mapbox/mapbox-gl-native/pull/16287))
* Fixed a memory leak when zooming with any options enabled in the `MGLMapView.debugMask` property. ([#15179](https://github.com/mapbox/mapbox-gl-native/issues/15179))

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;