From 453664ec9ca87980a3e24b092ef2f672a496965d Mon Sep 17 00:00:00 2001 From: Dave Prukop Date: Tue, 2 Oct 2018 16:41:33 -0700 Subject: Updated per comments. --- platform/ios/src/MGLMapView.mm | 7 ++++++- platform/macos/src/MGLMapView.mm | 9 +++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index 64a5424210..8d32bbeb68 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -3457,7 +3457,12 @@ public: } - (MGLMapCamera *)cameraThatFitsShape:(MGLShape *)shape direction:(CLLocationDirection)direction edgePadding:(UIEdgeInsets)insets { - return [self cameraThatFitsShape:shape direction:direction pitch:0 edgePadding:insets]; + mbgl::EdgeInsets padding = MGLEdgeInsetsFromNSEdgeInsets(insets); + padding += MGLEdgeInsetsFromNSEdgeInsets(self.contentInset); + + mbgl::CameraOptions cameraOptions = _mbglMap->cameraForGeometry([shape geometryObject], padding, direction); + + return [self cameraForCameraOptions:cameraOptions]; } - (MGLMapCamera *)cameraThatFitsShape:(MGLShape *)shape direction:(CLLocationDirection)direction pitch:(CGFloat)pitch edgePadding:(UIEdgeInsets)insets { diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm index fa49aa08c8..cc28b2bf9a 100644 --- a/platform/macos/src/MGLMapView.mm +++ b/platform/macos/src/MGLMapView.mm @@ -1303,12 +1303,17 @@ public: } - (MGLMapCamera *)cameraThatFitsShape:(MGLShape *)shape direction:(CLLocationDirection)direction edgePadding:(NSEdgeInsets)insets { - return [self cameraThatFitsShape:shape direction:direction pitch:0 edgePadding:insets]; + mbgl::EdgeInsets padding = MGLEdgeInsetsFromNSEdgeInsets(insets); + padding += MGLEdgeInsetsFromNSEdgeInsets(self.contentInsets); + + mbgl::CameraOptions cameraOptions = _mbglMap->cameraForGeometry([shape geometryObject], padding, direction); + + return [self cameraForCameraOptions:cameraOptions]; } - (MGLMapCamera *)cameraThatFitsShape:(MGLShape *)shape direction:(CLLocationDirection)direction pitch:(CGFloat)pitch edgePadding:(NSEdgeInsets)insets { mbgl::EdgeInsets padding = MGLEdgeInsetsFromNSEdgeInsets(insets); - padding += MGLEdgeInsetsFromNSEdgeInsets(self.contentInset); + padding += MGLEdgeInsetsFromNSEdgeInsets(self.contentInsets); mbgl::CameraOptions cameraOptions = _mbglMap->cameraForGeometry([shape geometryObject], padding, direction, pitch); -- cgit v1.2.1