summaryrefslogtreecommitdiff
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
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
-rw-r--r--platform/ios/CHANGELOG.md4
-rw-r--r--platform/ios/src/MGLMapView.mm2
-rw-r--r--platform/ios/uitest/MapViewTests.m17
-rw-r--r--platform/macos/CHANGELOG.md6
-rw-r--r--platform/macos/src/MGLMapView.mm2
5 files changed, 28 insertions, 3 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;
diff --git a/platform/macos/CHANGELOG.md b/platform/macos/CHANGELOG.md
index d2f5d1ccab..6f5c41feb0 100644
--- a/platform/macos/CHANGELOG.md
+++ b/platform/macos/CHANGELOG.md
@@ -1,5 +1,11 @@
# Changelog for Mapbox macOS SDK
+## 0.3.1
+
+This version of the Mapbox macOS SDK corresponds to version 3.4.1 of the Mapbox iOS SDK. The two SDKs have very similar feature sets. The main differences are the lack of user location tracking and annotation views. Some APIs have been adapted to macOS conventions, particularly the use of NSPopover for callout views.
+
+* 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))
+
## 0.3.0
This version of the Mapbox macOS SDK corresponds to version 3.4.0 of the Mapbox iOS SDK. The two SDKs have very similar feature sets. The main differences are the lack of user location tracking and annotation views. Some APIs have been adapted to macOS conventions, particularly the use of NSPopover for callout views.
diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm
index 3deb7db577..2b0d5f4bc8 100644
--- a/platform/macos/src/MGLMapView.mm
+++ b/platform/macos/src/MGLMapView.mm
@@ -1249,7 +1249,7 @@ public:
- (MGLMapCamera *)cameraForCameraOptions:(const mbgl::CameraOptions &)cameraOptions {
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,