From b2fd7b680c0bdcb5918424487aba9f083149c123 Mon Sep 17 00:00:00 2001 From: Jason Wray Date: Wed, 23 Aug 2017 16:06:12 -0400 Subject: [ios] Fix heading update loop Updating CLLocationManager.headingOrientation triggers a new heading update, even if there was no actual change in its value. --- platform/ios/CHANGELOG.md | 6 +++++- platform/ios/src/MGLMapView.mm | 17 +++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index e657472aa5..c17a73b059 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -2,7 +2,11 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONTRIBUTING.md](../../CONTRIBUTING.md) to get started. -## 3.6.2 +## 3.6.3 + +* Fixed an issue where user heading tracking mode would update too frequently. ([#9845](https://github.com/mapbox/mapbox-gl-native/pull/9845)) + +## 3.6.2 - August 18, 2017 * Added an `MGLStyle.localizesLabels` property, off by default, that localizes any Mapbox Streets–sourced symbol layer into the user’s preferred language. ([#9582](https://github.com/mapbox/mapbox-gl-native/pull/9582)) * Added an additional camera method to MGLMapView that accepts an edge padding parameter. ([#9651](https://github.com/mapbox/mapbox-gl-native/pull/9651)) diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index 715c32186d..18a8d2608a 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -4690,30 +4690,39 @@ public: { // note that right/left device and interface orientations are opposites (see UIApplication.h) // + CLDeviceOrientation orientation; switch ([[UIApplication sharedApplication] statusBarOrientation]) { case (UIInterfaceOrientationLandscapeLeft): { - self.locationManager.headingOrientation = CLDeviceOrientationLandscapeRight; + orientation = CLDeviceOrientationLandscapeRight; break; } case (UIInterfaceOrientationLandscapeRight): { - self.locationManager.headingOrientation = CLDeviceOrientationLandscapeLeft; + orientation = CLDeviceOrientationLandscapeLeft; break; } case (UIInterfaceOrientationPortraitUpsideDown): { - self.locationManager.headingOrientation = CLDeviceOrientationPortraitUpsideDown; + orientation = CLDeviceOrientationPortraitUpsideDown; break; } case (UIInterfaceOrientationPortrait): default: { - self.locationManager.headingOrientation = CLDeviceOrientationPortrait; + orientation = CLDeviceOrientationPortrait; break; } } + + // Setting the location manager's heading orientation causes it to send + // a heading event, which in turn makes us redraw, which kicks off a + // loop... so don't do that. rdar://34059173 + if (self.locationManager.headingOrientation != orientation) + { + self.locationManager.headingOrientation = orientation; + } } } -- cgit v1.2.1