From 41dd14d208e0f485e38a7e32f3eb8df4ef2d8f95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Wed, 18 Nov 2015 15:13:17 +0100 Subject: [PATCH] [Qt] expose NorthOrientation --- platform/qt/include/qmapboxgl.hpp | 11 +++++++++++ platform/qt/src/qmapboxgl.cpp | 22 ++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/platform/qt/include/qmapboxgl.hpp b/platform/qt/include/qmapboxgl.hpp index 3f5e3724f..83e5bb183 100644 --- a/platform/qt/include/qmapboxgl.hpp +++ b/platform/qt/include/qmapboxgl.hpp @@ -61,6 +61,14 @@ public: typedef QPair ShapeAnnotation; typedef QList ShapeAnnotations; + // Determines the orientation of the map. + enum NorthOrientation { + NorthUpwards, // Default + NorthRightwards, + NorthDownwards, + NorthLeftwards, + }; + QMapboxGL(QObject *parent = 0, const QMapboxGLSettings& = QMapboxGLSettings()); virtual ~QMapboxGL(); @@ -94,6 +102,9 @@ public: double pitch() const; void setPitch(double pitch, int milliseconds = 0); + NorthOrientation northOrientation() const; + void setNorthOrientation(NorthOrientation); + Coordinate coordinate() const; void setCoordinate(const Coordinate &, int milliseconds = 0); void setCoordinateZoom(const Coordinate &, double zoom, int milliseconds = 0); diff --git a/platform/qt/src/qmapboxgl.cpp b/platform/qt/src/qmapboxgl.cpp index b66e2407d..ae00eadbf 100644 --- a/platform/qt/src/qmapboxgl.cpp +++ b/platform/qt/src/qmapboxgl.cpp @@ -198,6 +198,28 @@ void QMapboxGL::setPitch(double pitch_, int milliseconds) d_ptr->mapObj->setPitch(pitch_, std::chrono::milliseconds(milliseconds)); } +QMapboxGL::NorthOrientation QMapboxGL::northOrientation() const +{ + using NO = mbgl::NorthOrientation; + switch (d_ptr->mapObj->getNorthOrientation()) { + case NO::Rightwards: return NorthRightwards; + case NO::Downwards: return NorthDownwards; + case NO::Leftwards: return NorthLeftwards; + default: return NorthUpwards; + } +} + +void QMapboxGL::setNorthOrientation(NorthOrientation orientation) +{ + using NO = mbgl::NorthOrientation; + switch (orientation) { + case NorthRightwards: d_ptr->mapObj->setNorthOrientation(NO::Rightwards); break; + case NorthDownwards: d_ptr->mapObj->setNorthOrientation(NO::Downwards); break; + case NorthLeftwards: d_ptr->mapObj->setNorthOrientation(NO::Leftwards); break; + default: d_ptr->mapObj->setNorthOrientation(NO::Upwards); break; + } +} + void QMapboxGL::setGestureInProgress(bool inProgress) { d_ptr->mapObj->setGestureInProgress(inProgress);