diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/map/map.cpp | 6 | ||||
-rw-r--r-- | src/mbgl/map/transform.cpp | 5 | ||||
-rw-r--r-- | src/mbgl/map/transform.hpp | 8 |
3 files changed, 18 insertions, 1 deletions
diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp index 51106db88b..a45a9ffaff 100644 --- a/src/mbgl/map/map.cpp +++ b/src/mbgl/map/map.cpp @@ -357,7 +357,11 @@ void Map::resetNorth(const Duration& duration) { #pragma mark - Pitch void Map::setPitch(double pitch, const Duration& duration) { - transform->setPitch(pitch * M_PI / 180, duration); + setPitch(pitch, {NAN, NAN}, duration); +} + +void Map::setPitch(double pitch, const PrecisionPoint& anchor, const Duration& duration) { + transform->setPitch(pitch * M_PI / 180, anchor, duration); update(Update::Repaint); } diff --git a/src/mbgl/map/transform.cpp b/src/mbgl/map/transform.cpp index b4743c0719..208f9a089a 100644 --- a/src/mbgl/map/transform.cpp +++ b/src/mbgl/map/transform.cpp @@ -523,12 +523,17 @@ double Transform::getAngle() const { #pragma mark - Pitch void Transform::setPitch(double pitch, const Duration& duration) { + setPitch(pitch, {NAN, NAN}, duration); +} + +void Transform::setPitch(double pitch, const PrecisionPoint& anchor, const Duration& duration) { if (std::isnan(pitch)) { return; } CameraOptions camera; camera.pitch = pitch; + camera.anchor = anchor; easeTo(camera, duration); } diff --git a/src/mbgl/map/transform.hpp b/src/mbgl/map/transform.hpp index bef6c6c87e..8c9ea08885 100644 --- a/src/mbgl/map/transform.hpp +++ b/src/mbgl/map/transform.hpp @@ -102,7 +102,15 @@ public: double getAngle() const; // Pitch + /** Sets the pitch angle. + @param angle The new pitch angle, measured in radians toward the + horizon. */ void setPitch(double pitch, const Duration& = Duration::zero()); + /** Sets the pitch angle, keeping the given point fixed within the view. + @param angle The new pitch angle, measured in radians toward the + horizon. + @param anchor A point relative to the top-left corner of the view. */ + void setPitch(double pitch, const PrecisionPoint& anchor, const Duration& = Duration::zero()); double getPitch() const; // North Orientation |