diff options
author | Fredrik Karlsson <bjorn.fredrik.karlsson@gmail.com> | 2019-03-11 14:04:44 +0100 |
---|---|---|
committer | Fredrik Karlsson <bjorn.fredrik.karlsson@gmail.com> | 2019-03-11 14:04:44 +0100 |
commit | d00d296cc43d0ce9b2645b7cf8cb48c2d86bac78 (patch) | |
tree | 4904367bd0b693d91921125659e3c672ed483aa7 | |
parent | 5ccc5b7c360827fe58698c28cae4df399310e4d1 (diff) | |
download | qtlocation-mapboxgl-upstream/fred/pad-inset.tar.gz |
[ios] add content inset to camera edge paddingupstream/fred/pad-inset
-rw-r--r-- | platform/darwin/src/MGLGeometry_Private.h | 3 | ||||
-rw-r--r-- | platform/ios/src/MGLMapView.mm | 9 |
2 files changed, 10 insertions, 2 deletions
diff --git a/platform/darwin/src/MGLGeometry_Private.h b/platform/darwin/src/MGLGeometry_Private.h index b91d4e0f81..652fe594f4 100644 --- a/platform/darwin/src/MGLGeometry_Private.h +++ b/platform/darwin/src/MGLGeometry_Private.h @@ -100,6 +100,9 @@ NS_INLINE BOOL MGLLocationCoordinate2DIsValid(CLLocationCoordinate2D coordinate) NS_INLINE mbgl::EdgeInsets MGLEdgeInsetsFromNSEdgeInsets(UIEdgeInsets insets) { return { insets.top, insets.left, insets.bottom, insets.right }; } +NS_INLINE UIEdgeInsets NSEdgeInsetsFromMGLEdgeInsets(mbgl::EdgeInsets insets) { + return UIEdgeInsetsMake(insets.top(), insets.left(), insets.bottom(), insets.right()); +} #else NS_INLINE mbgl::EdgeInsets MGLEdgeInsetsFromNSEdgeInsets(NSEdgeInsets insets) { return { insets.top, insets.left, insets.bottom, insets.right }; diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index 59bb1c6666..14903fcb6f 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -3649,8 +3649,13 @@ public: [self cancelTransitions]; self.cameraChangeReasonBitmask |= MGLCameraChangeReasonProgrammatic; - - mbgl::CameraOptions cameraOptions = [self cameraOptionsObjectForAnimatingToCamera:camera edgePadding:edgePadding]; + + mbgl::EdgeInsets padding = MGLEdgeInsetsFromNSEdgeInsets(edgePadding); + padding += MGLEdgeInsetsFromNSEdgeInsets(self.contentInset); + + mbgl::CameraOptions cameraOptions = [self cameraOptionsObjectForAnimatingToCamera:camera + edgePadding:NSEdgeInsetsFromMGLEdgeInsets(padding)]; + self.mbglMap.easeTo(cameraOptions, animationOptions); [self didChangeValueForKey:@"camera"]; } |