diff options
author | Lloyd Sheng <i@lloydsheng.com> | 2019-04-09 17:47:12 +0800 |
---|---|---|
committer | Lloyd Sheng <i@lloydsheng.com> | 2019-09-20 10:18:23 +0800 |
commit | 283894f3739eecbe2e502626c13b1a3aa1371592 (patch) | |
tree | 734a5c62a7737ac1d62c50463b35fe858995ea28 | |
parent | 8128d709b62189e0745ea64be3d35e8c6dab59fa (diff) | |
download | qtlocation-mapboxgl-283894f3739eecbe2e502626c13b1a3aa1371592.tar.gz |
Make sure attribution in proper position
-rw-r--r-- | platform/ios/src/MGLMapView.mm | 5 | ||||
-rw-r--r-- | platform/ios/test/MGLMapViewLayoutTests.m | 21 |
2 files changed, 26 insertions, 0 deletions
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index 62b943fd3d..edc127dd88 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -962,6 +962,11 @@ public: [self updateUserLocationAnnotationView]; [self updateAttributionAlertView]; + + if (!CGRectContainsRect(self.bounds, self.attributionButton.frame)) { + [NSException raise:NSInvalidArgumentException + format:@"The attribution 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/test/MGLMapViewLayoutTests.m b/platform/ios/test/MGLMapViewLayoutTests.m index 5d9c0339b5..f3eeb75c0d 100644 --- a/platform/ios/test/MGLMapViewLayoutTests.m +++ b/platform/ios/test/MGLMapViewLayoutTests.m @@ -211,6 +211,27 @@ } } +- (void)testAttributionButtonPlacementInvalidPosition { + CGFloat margin = -400.0; + + UIView *attributionButton = self.mapView.attributionButton; + NSArray *testDataList = [self makeTestDataListWithView:attributionButton margin:margin]; + + for (MGLOrnamentTestData *testData in testDataList) { + self.mapView.attributionButtonPosition = testData.position; + self.mapView.attributionButtonMargins = testData.offset; + + //invoke layout + [self.superView setNeedsLayout]; + XCTAssertThrowsSpecificNamed( + [self.superView layoutIfNeeded], + NSException, + NSInvalidArgumentException, + @"should throw NSInvalidArgumentException" + ); + } +} + - (void)testLogoPlacement { double accuracy = 0.01; CGFloat margin = 4.0; |