summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorJordan Moncharmont <jormon@gmail.com>2016-01-22 18:17:30 -0800
committerMinh Nguyễn <mxn@1ec5.org>2016-02-01 20:55:55 -0800
commit909832624e3c3afa28f98e109c5bae188a4f3120 (patch)
tree105f4b0a7f45ef12141062c8010949bff791e082 /platform
parent52689796dfed796a1e949d39be411ccca3041933 (diff)
downloadqtlocation-mapboxgl-909832624e3c3afa28f98e109c5bae188a4f3120.tar.gz
Custom edgeInsets for fitting in showAnnotations
Keeps sensible defaults already in place, but allows callers to override.
Diffstat (limited to 'platform')
-rw-r--r--platform/ios/src/MGLMapView.mm19
1 files changed, 14 insertions, 5 deletions
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index dfac4db862..beb0438591 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -2952,6 +2952,19 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration)
- (void)showAnnotations:(NS_ARRAY_OF(id <MGLAnnotation>) *)annotations animated:(BOOL)animated
{
+ 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;
+
+ UIEdgeInsets edgeInsets = UIEdgeInsetsMake(yPadding, xPadding, yPadding, xPadding);
+
+ [self showAnnotations:annotations
+ withEdgeInsets:edgeInsets
+ animated:animated];
+}
+
+- (void)showAnnotations:(NS_ARRAY_OF(id <MGLAnnotation>) *)annotations withEdgeInsets:(UIEdgeInsets)edgeInsets animated:(BOOL)animated
+{
if ( ! annotations || ! annotations.count) return;
mbgl::LatLngBounds bounds = mbgl::LatLngBounds::getExtendable();
@@ -2968,12 +2981,8 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval 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(yPadding, xPadding, yPadding, xPadding)
+ edgePadding:edgeInsets
animated:animated];
}