summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLloyd Sheng <i@lloydsheng.com>2019-09-17 17:49:40 +0800
committerLloyd Sheng <i@lloydsheng.com>2019-09-20 10:18:24 +0800
commit7024716992ef29377a393b427635bc1116bcaaee (patch)
tree62230d02eea95b14e9b510e7aa32198495d355a2
parentb1a0cc3008cc7c6ce684724f1dcefd7479419b8b (diff)
downloadqtlocation-mapboxgl-7024716992ef29377a393b427635bc1116bcaaee.tar.gz
Fix issues and add changelog
-rw-r--r--platform/ios/CHANGELOG.md1
-rw-r--r--platform/ios/src/MGLMapView.mm24
-rw-r--r--platform/ios/src/UIView+MGLAdditions.h2
-rw-r--r--platform/ios/src/UIView+MGLAdditions.m2
-rw-r--r--platform/ios/test/MGLMapViewLayoutTests.m41
5 files changed, 32 insertions, 38 deletions
diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md
index 490a87d274..170189d539 100644
--- a/platform/ios/CHANGELOG.md
+++ b/platform/ios/CHANGELOG.md
@@ -19,6 +19,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT
* Fixed an issue that caused the tilt gesture to trigger too easily and conflict with pinch or pan gestures. ([#15349](https://github.com/mapbox/mapbox-gl-native/pull/15349))
* Fixed an issue that caused the map to rotate too easily during a pinch gesture. [(#15562)](https://github.com/mapbox/mapbox-gl-native/pull/15562)
+* Fixed an issue that ornaments could be setting outside the mapview. [(#14373)](https://github.com/mapbox/mapbox-gl-native/pull/14373)
### Performance improvements
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index a445b0890f..4d654c79d8 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -963,22 +963,14 @@ public:
[self updateAttributionAlertView];
- if (!CGRectContainsRect(self.bounds, self.attributionButton.mgl_frameForTransformIdentity)) {
- [NSException raise:NSInvalidArgumentException
- format:@"The attribution is not in the visible area of the mapview. Please check your position and offset settings"];
- }
- if (!CGRectContainsRect(self.bounds, self.scaleBar.mgl_frameForTransformIdentity)) {
- [NSException raise:NSInvalidArgumentException
- format:@"The scaleBar is not in the visible area of the mapview. Please check your position and offset settings"];
- }
- if (!CGRectContainsRect(self.bounds, self.compassView.mgl_frameForTransformIdentity)) {
- [NSException raise:NSInvalidArgumentException
- format:@"The compassView is not in the visible area of the mapview. Please check your position and offset settings"];
- }
- if (!CGRectContainsRect(self.bounds, self.logoView.mgl_frameForTransformIdentity)) {
- [NSException raise:NSInvalidArgumentException
- format:@"The logoView is not in the visible area of the mapview. Please check your position and offset settings"];
- }
+ MGLAssert(CGRectContainsRect(self.bounds, self.attributionButton.mgl_frameForIdentifyTransform),
+ @"The attribution is not in the visible area of the mapview. Please check your position and offset settings");
+ MGLAssert(CGRectContainsRect(self.bounds, self.scaleBar.mgl_frameForIdentifyTransform),
+ @"The scaleBar is not in the visible area of the mapview. Please check your position and offset settings");
+ MGLAssert(CGRectContainsRect(self.bounds, self.compassView.mgl_frameForIdentifyTransform),
+ @"The compassView is not in the visible area of the mapview. Please check your position and offset settings");
+ MGLAssert(CGRectContainsRect(self.bounds, self.logoView.mgl_frameForIdentifyTransform),
+ @"The logoView is not in the visible area of the mapview. Please check your position and offset settings");
}
/// Updates `contentInset` to reflect the current window geometry.
diff --git a/platform/ios/src/UIView+MGLAdditions.h b/platform/ios/src/UIView+MGLAdditions.h
index ba9f650c38..3395ab999c 100644
--- a/platform/ios/src/UIView+MGLAdditions.h
+++ b/platform/ios/src/UIView+MGLAdditions.h
@@ -14,7 +14,7 @@ NS_ASSUME_NONNULL_BEGIN
- (NSLayoutXAxisAnchor *)mgl_safeTrailingAnchor;
-- (CGRect)mgl_frameForTransformIdentity;
+- (CGRect)mgl_frameForIdentifyTransform;
@end
diff --git a/platform/ios/src/UIView+MGLAdditions.m b/platform/ios/src/UIView+MGLAdditions.m
index 5106cb0caa..802ceb0704 100644
--- a/platform/ios/src/UIView+MGLAdditions.m
+++ b/platform/ios/src/UIView+MGLAdditions.m
@@ -66,7 +66,7 @@
}
}
-- (CGRect)mgl_frameForTransformIdentity {
+- (CGRect)mgl_frameForIdentifyTransform {
CGPoint center = self.center;
CGSize size = self.bounds.size;
diff --git a/platform/ios/test/MGLMapViewLayoutTests.m b/platform/ios/test/MGLMapViewLayoutTests.m
index 21b8e0d979..206753c6e4 100644
--- a/platform/ios/test/MGLMapViewLayoutTests.m
+++ b/platform/ios/test/MGLMapViewLayoutTests.m
@@ -7,13 +7,13 @@
@interface UIView (MGLAdditions)
-- (CGRect)mgl_frameForTransformIdentity;
+- (CGRect)mgl_frameForIdentifyTransform;
@end
@implementation UIView (MGLAdditions)
-- (CGRect)mgl_frameForTransformIdentity {
+- (CGRect)mgl_frameForIdentifyTransform {
CGPoint center = self.center;
CGSize size = self.bounds.size;
@@ -190,8 +190,8 @@
[self.superView setNeedsLayout];
[self.superView layoutIfNeeded];
- XCTAssertEqualWithAccuracy(CGRectGetMinX(compassView.mgl_frameForTransformIdentity), testData.expectedOrigin.x, accuracy);
- XCTAssertEqualWithAccuracy(CGRectGetMinY(compassView.mgl_frameForTransformIdentity), testData.expectedOrigin.y, accuracy);
+ XCTAssertEqualWithAccuracy(CGRectGetMinX(compassView.mgl_frameForIdentifyTransform), testData.expectedOrigin.x, accuracy);
+ XCTAssertEqualWithAccuracy(CGRectGetMinY(compassView.mgl_frameForIdentifyTransform), testData.expectedOrigin.y, accuracy);
}
}
@@ -205,14 +205,15 @@
for (MGLOrnamentTestData *testData in testDataList) {
self.mapView.compassViewPosition = testData.position;
self.mapView.compassViewMargins = testData.offset;
+ // A tranform value which would led compassView's frame outside mapview's bounds
self.mapView.compassView.transform = CGAffineTransformMake(0.7, -0.8, 0.6, 0.7, 0, 0);
//invoke layout
[self.superView setNeedsLayout];
[self.superView layoutIfNeeded];
- XCTAssertEqualWithAccuracy(CGRectGetMinX(compassView.mgl_frameForTransformIdentity), testData.expectedOrigin.x, accuracy);
- XCTAssertEqualWithAccuracy(CGRectGetMinY(compassView.mgl_frameForTransformIdentity), testData.expectedOrigin.y, accuracy);
+ XCTAssertEqualWithAccuracy(CGRectGetMinX(compassView.mgl_frameForIdentifyTransform), testData.expectedOrigin.x, accuracy);
+ XCTAssertEqualWithAccuracy(CGRectGetMinY(compassView.mgl_frameForIdentifyTransform), testData.expectedOrigin.y, accuracy);
}
}
@@ -231,8 +232,8 @@
XCTAssertThrowsSpecificNamed(
[self.superView layoutIfNeeded],
NSException,
- NSInvalidArgumentException,
- @"should throw NSInvalidArgumentException"
+ NSInternalInconsistencyException,
+ @"should throw NSInternalInconsistencyException"
);
}
}
@@ -252,8 +253,8 @@
[self.superView setNeedsLayout];
[self.superView layoutIfNeeded];
- XCTAssertEqualWithAccuracy(CGRectGetMinX(scaleBar.mgl_frameForTransformIdentity), testData.expectedOrigin.x, accuracy);
- XCTAssertEqualWithAccuracy(CGRectGetMinY(scaleBar.mgl_frameForTransformIdentity), testData.expectedOrigin.y, accuracy);
+ XCTAssertEqualWithAccuracy(CGRectGetMinX(scaleBar.mgl_frameForIdentifyTransform), testData.expectedOrigin.x, accuracy);
+ XCTAssertEqualWithAccuracy(CGRectGetMinY(scaleBar.mgl_frameForIdentifyTransform), testData.expectedOrigin.y, accuracy);
}
}
@@ -272,8 +273,8 @@
XCTAssertThrowsSpecificNamed(
[self.superView layoutIfNeeded],
NSException,
- NSInvalidArgumentException,
- @"should throw NSInvalidArgumentException"
+ NSInternalInconsistencyException,
+ @"should throw NSInternalInconsistencyException"
);
}
}
@@ -293,8 +294,8 @@
[self.superView setNeedsLayout];
[self.superView layoutIfNeeded];
- XCTAssertEqualWithAccuracy(CGRectGetMinX(attributionButton.mgl_frameForTransformIdentity), testData.expectedOrigin.x, accuracy);
- XCTAssertEqualWithAccuracy(CGRectGetMinY(attributionButton.mgl_frameForTransformIdentity), testData.expectedOrigin.y, accuracy);
+ XCTAssertEqualWithAccuracy(CGRectGetMinX(attributionButton.mgl_frameForIdentifyTransform), testData.expectedOrigin.x, accuracy);
+ XCTAssertEqualWithAccuracy(CGRectGetMinY(attributionButton.mgl_frameForIdentifyTransform), testData.expectedOrigin.y, accuracy);
}
}
@@ -313,8 +314,8 @@
XCTAssertThrowsSpecificNamed(
[self.superView layoutIfNeeded],
NSException,
- NSInvalidArgumentException,
- @"should throw NSInvalidArgumentException"
+ NSInternalInconsistencyException,
+ @"should throw NSInternalInconsistencyException"
);
}
}
@@ -334,8 +335,8 @@
[self.superView setNeedsLayout];
[self.superView layoutIfNeeded];
- XCTAssertEqualWithAccuracy(CGRectGetMinX(logoView.mgl_frameForTransformIdentity), testData.expectedOrigin.x, accuracy);
- XCTAssertEqualWithAccuracy(CGRectGetMinY(logoView.mgl_frameForTransformIdentity), testData.expectedOrigin.y, accuracy);
+ XCTAssertEqualWithAccuracy(CGRectGetMinX(logoView.mgl_frameForIdentifyTransform), testData.expectedOrigin.x, accuracy);
+ XCTAssertEqualWithAccuracy(CGRectGetMinY(logoView.mgl_frameForIdentifyTransform), testData.expectedOrigin.y, accuracy);
}
}
@@ -354,8 +355,8 @@
XCTAssertThrowsSpecificNamed(
[self.superView layoutIfNeeded],
NSException,
- NSInvalidArgumentException,
- @"should throw NSInvalidArgumentException"
+ NSInternalInconsistencyException,
+ @"should throw NSInternalInconsistencyException"
);
}
}