From 2aa1e5ca18cbff64501881ab6b799f2890b57b2b Mon Sep 17 00:00:00 2001 From: Jason Wray Date: Wed, 23 Dec 2015 20:08:03 -0500 Subject: [PATCH] [ios] vary annotation bounds fit padding based on view size Fix #3392, #3110 --- CHANGELOG.md | 1 + platform/ios/src/MGLMapView.mm | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ab11b36a..60769096d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,7 @@ Known issues: - A new method on MGLMapView, `-flyToCamera:withDuration:completionHandler:`, lets you transition between viewpoints along an arc as if by aircraft. ([#3171](https://github.com/mapbox/mapbox-gl-native/pull/3171), [#3301](https://github.com/mapbox/mapbox-gl-native/pull/3301)) - MGLMapCamera’s `altitude` values now match those of MKMapCamera. ([#3362](https://github.com/mapbox/mapbox-gl-native/pull/3362)) - The user dot’s callout view is now centered above the user dot. It was previously offset slightly to the left. ([#3261](https://github.com/mapbox/mapbox-gl-native/pull/3261)) +- Fixed an issue with small map views not properly fitting annotations within bounds. (#[3407](https://github.com/mapbox/mapbox-gl-native/pull/3407)) ## iOS 3.0.1 diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index f85816e44..af3adae6b 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -2653,8 +2653,12 @@ std::chrono::steady_clock::duration MGLDurationInSeconds(float duration) } } + CGFloat defaultPadding = 100; + CGFloat yPadding = (self.frame.size.height / 2 <= defaultPadding) ? (self.frame.size.height / 5) : defaultPadding; + CGFloat xPadding = (self.frame.size.width / 2 <= defaultPadding) ? (self.frame.size.width / 5) : defaultPadding; + [self setVisibleCoordinateBounds:MGLCoordinateBoundsFromLatLngBounds(bounds) - edgePadding:UIEdgeInsetsMake(100, 100, 100, 100) + edgePadding:UIEdgeInsetsMake(yPadding, xPadding, yPadding, xPadding) animated:animated]; }