summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2019-03-01 10:14:07 +0200
committerBruno de Oliveira Abinader <bruno@mapbox.com>2019-03-04 14:45:32 +0200
commit74538406e9e7f9444e491ea23b7dc52f63d77e73 (patch)
treede33864711e71a4de4054ce64729309f914e6caa
parent586b22c0df99dec7e2089ba938cfbd8f96b3ce18 (diff)
downloadqtlocation-mapboxgl-74538406e9e7f9444e491ea23b7dc52f63d77e73.tar.gz
[core] Organize Map::{move,pitch,scale,rotate}By
-rw-r--r--include/mbgl/map/map.hpp16
-rw-r--r--src/mbgl/map/map.cpp26
2 files changed, 13 insertions, 29 deletions
diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp
index 3d7223308b..55f2ab2895 100644
--- a/include/mbgl/map/map.hpp
+++ b/include/mbgl/map/map.hpp
@@ -68,20 +68,15 @@ public:
void jumpTo(const CameraOptions&);
void easeTo(const CameraOptions&, const AnimationOptions&);
void flyTo(const CameraOptions&, const AnimationOptions&);
+ void moveBy(const ScreenCoordinate&, const AnimationOptions& = {});
+ void scaleBy(double scale, optional<ScreenCoordinate> anchor, const AnimationOptions& animation = {});
+ void pitchBy(double pitch, const AnimationOptions& animation = {});
+ void rotateBy(const ScreenCoordinate& first, const ScreenCoordinate& second, const AnimationOptions& = {});
CameraOptions cameraForLatLngBounds(const LatLngBounds&, const EdgeInsets&, optional<double> bearing = {}, optional<double> pitch = {}) const;
CameraOptions cameraForLatLngs(const std::vector<LatLng>&, const EdgeInsets&, optional<double> bearing = {}, optional<double> pitch = {}) const;
CameraOptions cameraForGeometry(const Geometry<double>&, const EdgeInsets&, optional<double> bearing = {}, optional<double> pitch = {}) const;
LatLngBounds latLngBoundsForCamera(const CameraOptions&) const;
- // Position
- void moveBy(const ScreenCoordinate&, const AnimationOptions& = {});
-
- // Zoom
- void scaleBy(double scale, optional<ScreenCoordinate> anchor, const AnimationOptions& animation = {});
-
- // Pitch
- void pitchBy(double pitch, const AnimationOptions& animation = {});
-
// Bounds
void setLatLngBounds(optional<LatLngBounds>);
optional<LatLngBounds> getLatLngBounds() const;
@@ -94,9 +89,6 @@ public:
void setMaxPitch(double);
double getMaxPitch() const;
- // Rotation
- void rotateBy(const ScreenCoordinate& first, const ScreenCoordinate& second, const AnimationOptions& = {});
-
// North Orientation
void setNorthOrientation(NorthOrientation);
NorthOrientation getNorthOrientation() const;
diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp
index e2b56b8d55..7fe99e3867 100644
--- a/src/mbgl/map/map.cpp
+++ b/src/mbgl/map/map.cpp
@@ -159,21 +159,27 @@ void Map::flyTo(const CameraOptions& camera, const AnimationOptions& animation)
impl->onUpdate();
}
-#pragma mark - Position
-
void Map::moveBy(const ScreenCoordinate& point, const AnimationOptions& animation) {
impl->cameraMutated = true;
impl->transform.moveBy(point, animation);
impl->onUpdate();
}
-#pragma mark - Zoom
+void Map::pitchBy(double pitch, const AnimationOptions& animation) {
+ easeTo(CameraOptions().withPitch((impl->transform.getPitch() * util::RAD2DEG) - pitch), animation);
+}
void Map::scaleBy(double scale, optional<ScreenCoordinate> anchor, const AnimationOptions& animation) {
const double zoom = impl->transform.getZoom() + impl->transform.getState().scaleZoom(scale);
easeTo(CameraOptions().withZoom(zoom).withAnchor(anchor), animation);
}
+void Map::rotateBy(const ScreenCoordinate& first, const ScreenCoordinate& second, const AnimationOptions& animation) {
+ impl->cameraMutated = true;
+ impl->transform.rotateBy(first, second, animation);
+ impl->onUpdate();
+}
+
CameraOptions Map::cameraForLatLngBounds(const LatLngBounds& bounds, const EdgeInsets& padding, optional<double> bearing, optional<double> pitch) const {
return cameraForLatLngs({
bounds.northwest(),
@@ -270,12 +276,6 @@ LatLngBounds Map::latLngBoundsForCamera(const CameraOptions& camera) const {
);
}
-#pragma mark - Pitch
-
-void Map::pitchBy(double pitch, const AnimationOptions& animation) {
- easeTo(CameraOptions().withPitch((impl->transform.getPitch() * util::RAD2DEG) - pitch), animation);
-}
-
#pragma mark - Bounds
optional<LatLngBounds> Map::getLatLngBounds() const {
@@ -343,14 +343,6 @@ Size Map::getSize() const {
return impl->transform.getState().getSize();
}
-#pragma mark - Rotation
-
-void Map::rotateBy(const ScreenCoordinate& first, const ScreenCoordinate& second, const AnimationOptions& animation) {
- impl->cameraMutated = true;
- impl->transform.rotateBy(first, second, animation);
- impl->onUpdate();
-}
-
#pragma mark - North Orientation
void Map::setNorthOrientation(NorthOrientation orientation) {