summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Prukop <dave.prukop@mapbox.com>2018-10-02 15:50:04 -0700
committerDave Prukop <dave.prukop@mapbox.com>2018-10-02 15:50:04 -0700
commit3ac3ffcf5fa0631716a668c5d32dfca74a62e927 (patch)
tree2977e17faa97b9cfaeff46062338f209918bd999
parent41dd886ce5e0b20657d7b859b775949055129906 (diff)
downloadqtlocation-mapboxgl-3ac3ffcf5fa0631716a668c5d32dfca74a62e927.tar.gz
Added cameraThatFitsShape: direction: pitch: edgePadding: method
-rw-r--r--platform/ios/src/MGLMapView.h14
-rw-r--r--platform/ios/src/MGLMapView.mm6
-rw-r--r--platform/macos/src/MGLMapView.h14
-rw-r--r--platform/macos/src/MGLMapView.mm12
4 files changed, 41 insertions, 5 deletions
diff --git a/platform/ios/src/MGLMapView.h b/platform/ios/src/MGLMapView.h
index 02d146edcb..c11c8b271a 100644
--- a/platform/ios/src/MGLMapView.h
+++ b/platform/ios/src/MGLMapView.h
@@ -1029,6 +1029,20 @@ MGL_EXPORT IB_DESIGNABLE
- (MGLMapCamera *)cameraThatFitsShape:(MGLShape *)shape direction:(CLLocationDirection)direction edgePadding:(UIEdgeInsets)insets;
/**
+ Returns the camera that best fits the given shape, with the specified direction and pitch,
+ optionally with some additional padding on each side.
+
+ @param shape The shape to fit to the receiver’s viewport.
+ @param direction The direction of the viewport, measured in degrees clockwise from true north.
+ @param pitch of the map to use in evaluating the shape to fit.
+ @param insets The minimum padding (in screen points) that would be visible
+ around the returned camera object if it were set as the receiver’s camera.
+ @return A camera object centered on the shape's center with zoom level as high
+ (close to the ground) as possible while still including the entire shape.
+ */
+- (MGLMapCamera *)cameraThatFitsShape:(MGLShape *)shape direction:(CLLocationDirection)direction pitch:(CGFloat)pitch edgePadding:(UIEdgeInsets)insets;
+
+/**
Returns the point in this view’s coordinate system on which to "anchor" in
response to a user-initiated gesture.
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index 12c86f1d97..64a5424210 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -3457,10 +3457,14 @@ public:
}
- (MGLMapCamera *)cameraThatFitsShape:(MGLShape *)shape direction:(CLLocationDirection)direction edgePadding:(UIEdgeInsets)insets {
+ return [self cameraThatFitsShape:shape direction:direction pitch:0 edgePadding:insets];
+}
+
+- (MGLMapCamera *)cameraThatFitsShape:(MGLShape *)shape direction:(CLLocationDirection)direction pitch:(CGFloat)pitch edgePadding:(UIEdgeInsets)insets {
mbgl::EdgeInsets padding = MGLEdgeInsetsFromNSEdgeInsets(insets);
padding += MGLEdgeInsetsFromNSEdgeInsets(self.contentInset);
- mbgl::CameraOptions cameraOptions = _mbglMap->cameraForGeometry([shape geometryObject], padding, direction);
+ mbgl::CameraOptions cameraOptions = _mbglMap->cameraForGeometry([shape geometryObject], padding, direction, pitch);
return [self cameraForCameraOptions:cameraOptions];
}
diff --git a/platform/macos/src/MGLMapView.h b/platform/macos/src/MGLMapView.h
index ddb5747109..214a69b8bf 100644
--- a/platform/macos/src/MGLMapView.h
+++ b/platform/macos/src/MGLMapView.h
@@ -531,6 +531,20 @@ MGL_EXPORT IB_DESIGNABLE
- (MGLMapCamera *)cameraThatFitsShape:(MGLShape *)shape direction:(CLLocationDirection)direction edgePadding:(NSEdgeInsets)insets;
/**
+ Returns the camera that best fits the given shape, with the specified direction and pitch,
+ optionally with some additional padding on each side.
+
+ @param shape The shape to fit to the receiver’s viewport.
+ @param direction The direction of the viewport, measured in degrees clockwise from true north.
+ @param pitch of the map to use in evaluating the shape to fit.
+ @param insets The minimum padding (in screen points) that would be visible
+ around the returned camera object if it were set as the receiver’s camera.
+ @return A camera object centered on the shape's center with zoom level as high
+ (close to the ground) as possible while still including the entire shape.
+ */
+- (MGLMapCamera *)cameraThatFitsShape:(MGLShape *)shape direction:(CLLocationDirection)direction pitch:(CGFloat)pitch edgePadding:(NSEdgeInsets)insets;
+
+/**
A Boolean value indicating whether the receiver automatically adjusts its
content insets.
diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm
index 919c6d1fbc..fa49aa08c8 100644
--- a/platform/macos/src/MGLMapView.mm
+++ b/platform/macos/src/MGLMapView.mm
@@ -1303,11 +1303,15 @@ public:
}
- (MGLMapCamera *)cameraThatFitsShape:(MGLShape *)shape direction:(CLLocationDirection)direction edgePadding:(NSEdgeInsets)insets {
- mbgl::EdgeInsets padding = MGLEdgeInsetsFromNSEdgeInsets(insets);
- padding += MGLEdgeInsetsFromNSEdgeInsets(self.contentInsets);
-
- mbgl::CameraOptions cameraOptions = _mbglMap->cameraForGeometry([shape geometryObject], padding, direction);
+ return [self cameraThatFitsShape:shape direction:direction pitch:0 edgePadding:insets];
+}
+- (MGLMapCamera *)cameraThatFitsShape:(MGLShape *)shape direction:(CLLocationDirection)direction pitch:(CGFloat)pitch edgePadding:(NSEdgeInsets)insets {
+ mbgl::EdgeInsets padding = MGLEdgeInsetsFromNSEdgeInsets(insets);
+ padding += MGLEdgeInsetsFromNSEdgeInsets(self.contentInset);
+
+ mbgl::CameraOptions cameraOptions = _mbglMap->cameraForGeometry([shape geometryObject], padding, direction, pitch);
+
return [self cameraForCameraOptions:cameraOptions];
}