summaryrefslogtreecommitdiff
path: root/platform/ios
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2017-01-24 08:29:46 -0800
committerGitHub <noreply@github.com>2017-01-24 08:29:46 -0800
commit35e062d72cde411e8a9a36ef74cbe527d31e945b (patch)
tree74a668219e317fd7fd36710034e540d3e5df3a90 /platform/ios
parentb32c17119e5b046aab796a29e321759095a0959b (diff)
downloadqtlocation-mapboxgl-35e062d72cde411e8a9a36ef74cbe527d31e945b.tar.gz
[ios, macos] Wrap camera heading (#7724)
* [ios, macos] Fixed negative camera heading when facing northwest * [ios] Corrected counterclockwise rotation test
Diffstat (limited to 'platform/ios')
-rw-r--r--platform/ios/CHANGELOG.md4
-rw-r--r--platform/ios/src/MGLMapView.mm2
-rw-r--r--platform/ios/uitest/MapViewTests.m17
3 files changed, 21 insertions, 2 deletions
diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md
index 0e28bf153d..6f6daf6be0 100644
--- a/platform/ios/CHANGELOG.md
+++ b/platform/ios/CHANGELOG.md
@@ -2,6 +2,10 @@
Mapbox welcomes participation and contributions from everyone. Please read [CONTRIBUTING.md](../../CONTRIBUTING.md) to get started.
+## 3.4.1
+
+* Fixed an issue causing MGLMapView’s `camera`’s `heading` to be set to a negative value, indicating an undefined heading, when the map view faces northwest. The heading is now wrapped to between zero and 360 degrees, for consistency with MGLMapView’s `direction` property. ([#7724](https://github.com/mapbox/mapbox-gl-native/pull/7724))
+
## 3.4.0
### Packaging
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index ba40997bc3..acc6a3f13c 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -2625,7 +2625,7 @@ public:
{
CLLocationCoordinate2D centerCoordinate = MGLLocationCoordinate2DFromLatLng(cameraOptions.center ? *cameraOptions.center : _mbglMap->getLatLng());
double zoomLevel = cameraOptions.zoom ? *cameraOptions.zoom : self.zoomLevel;
- CLLocationDirection direction = cameraOptions.angle ? -MGLDegreesFromRadians(*cameraOptions.angle) : self.direction;
+ CLLocationDirection direction = cameraOptions.angle ? mbgl::util::wrap(-MGLDegreesFromRadians(*cameraOptions.angle), 0., 360.) : self.direction;
CGFloat pitch = cameraOptions.pitch ? MGLDegreesFromRadians(*cameraOptions.pitch) : _mbglMap->getPitch();
CLLocationDistance altitude = MGLAltitudeForZoomLevel(zoomLevel, pitch, centerCoordinate.latitude, self.frame.size);
return [MGLMapCamera cameraLookingAtCenterCoordinate:centerCoordinate fromDistance:altitude pitch:pitch heading:direction];
diff --git a/platform/ios/uitest/MapViewTests.m b/platform/ios/uitest/MapViewTests.m
index 41ea5446ef..21310b47a6 100644
--- a/platform/ios/uitest/MapViewTests.m
+++ b/platform/ios/uitest/MapViewTests.m
@@ -260,7 +260,7 @@
@"disabling pan gesture should disallow horizontal panning");
}
-- (void)testRotate {
+- (void)testRotateClockwise {
CLLocationDirection startAngle = tester.mapView.direction;
XCTAssertNotEqual(startAngle,
@@ -274,6 +274,21 @@
@"rotating map should change angle");
}
+- (void)testRotateCounterclockwise {
+ CLLocationDirection startAngle = tester.mapView.direction;
+
+ XCTAssertNotEqual(startAngle,
+ -45,
+ @"start angle must not be destination angle");
+
+ [tester.mapView twoFingerRotateAtPoint:tester.mapView.center angle:-45];
+
+ XCTAssertGreaterThanOrEqual(fabs(startAngle - tester.mapView.direction),
+ 20,
+ @"rotating map should change angle");
+ XCTAssertGreaterThan(tester.mapView.camera.heading, 0, @"camera should not go negative");
+}
+
- (void)testRotateDisabled {
tester.mapView.rotateEnabled = NO;
CLLocationDirection startAngle = tester.mapView.direction;