[core] Added Map::pitchBy()
This commit is contained in:
@@ -90,6 +90,9 @@ public:
|
||||
void setLatLngZoom(const LatLng&, double zoom, const EdgeInsets&, const AnimationOptions& = {});
|
||||
void resetZoom();
|
||||
|
||||
// Pitch
|
||||
void pitchBy(double pitch, const AnimationOptions& animation = {});
|
||||
|
||||
// Bounds
|
||||
void setLatLngBounds(optional<LatLngBounds>);
|
||||
optional<LatLngBounds> getLatLngBounds() const;
|
||||
|
||||
@@ -553,7 +553,7 @@ void GLFWView::onMouseMove(GLFWwindow *window, double x, double y) {
|
||||
} else if (view->pitching) {
|
||||
const double dy = y - view->lastY;
|
||||
if (dy) {
|
||||
view->map->setPitch(view->map->getPitch() - dy / 2);
|
||||
view->map->pitchBy(dy / 2);
|
||||
}
|
||||
}
|
||||
view->lastX = x;
|
||||
|
||||
@@ -437,7 +437,7 @@ void MapWindow::mouseMoveEvent(QMouseEvent *ev)
|
||||
|
||||
if (!delta.isNull()) {
|
||||
if (ev->buttons() == Qt::LeftButton && ev->modifiers() & Qt::ShiftModifier) {
|
||||
m_map->setPitch(m_map->pitch() - delta.y());
|
||||
m_map->pitchBy(delta.y());
|
||||
} else if (ev->buttons() == Qt::LeftButton) {
|
||||
m_map->moveBy(delta);
|
||||
} else if (ev->buttons() == Qt::RightButton) {
|
||||
|
||||
@@ -182,6 +182,7 @@ public:
|
||||
|
||||
double pitch() const;
|
||||
void setPitch(double pitch);
|
||||
void pitchBy(double pitch);
|
||||
|
||||
NorthOrientation northOrientation() const;
|
||||
void setNorthOrientation(NorthOrientation);
|
||||
|
||||
@@ -885,6 +885,11 @@ void QMapboxGL::setPitch(double pitch_)
|
||||
d_ptr->mapObj->setPitch(pitch_);
|
||||
}
|
||||
|
||||
void QMapboxGL::pitchBy(double pitch_)
|
||||
{
|
||||
d_ptr->mapObj->pitchBy(pitch_);
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the north orientation mode.
|
||||
*/
|
||||
|
||||
@@ -317,6 +317,12 @@ void Map::resetZoom() {
|
||||
setZoom(0);
|
||||
}
|
||||
|
||||
#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 {
|
||||
|
||||
Reference in New Issue
Block a user