summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSanjiban Bairagya <sanjiban22393@gmail.com>2016-07-18 18:40:50 (GMT)
committerSanjiban Bairagya <sanjiban@magicpin.in>2016-07-18 18:41:21 (GMT)
commit61c2384729acc6e1a5a39f3af3b8dcdd72024151 (patch)
treef4150b6aab70e61457d81c3733e5d8aac6d1e99c
parent0c0cdfbb6f607fdf7e39177ac4a0a9693947a626 (diff)
Teach AutoNavigation to center on the route-fixed position
instead of GPS location, when navigating on route
-rw-r--r--src/lib/marble/AutoNavigation.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/lib/marble/AutoNavigation.cpp b/src/lib/marble/AutoNavigation.cpp
index 3eb17d4..5948544 100644
--- a/src/lib/marble/AutoNavigation.cpp
+++ b/src/lib/marble/AutoNavigation.cpp
@@ -19,6 +19,9 @@
#include "MarbleMath.h"
#include "ViewportParams.h"
#include "MarbleGlobal.h"
+#include "RoutingManager.h"
+#include "RoutingModel.h"
+#include "Route.h"
#include <QWidget>
#include <QRect>
@@ -37,9 +40,9 @@ public:
const ViewportParams *const m_viewport;
const PositionTracking *const m_tracking;
AutoNavigation::CenterMode m_recenterMode;
- bool m_adjustZoom;
- QTimer m_lastWidgetInteraction;
- bool m_selfInteraction;
+ bool m_adjustZoom;
+ QTimer m_lastWidgetInteraction;
+ bool m_selfInteraction;
/** Constructor */
Private( MarbleModel *model, const ViewportParams *viewport, AutoNavigation *parent );
@@ -298,7 +301,14 @@ void AutoNavigation::Private::adjustZoom( const GeoDataCoordinates &currentPosit
void AutoNavigation::Private::centerOn( const GeoDataCoordinates &position )
{
m_selfInteraction = true;
- emit m_parent->centerOn( position, false );
+ RoutingManager const * routingManager = m_model->routingManager();
+ RoutingModel const * routingModel = routingManager->routingModel();
+ if (!routingManager->guidanceModeEnabled() || routingModel->deviatedFromRoute()){
+ emit m_parent->centerOn( position, false );
+ } else {
+ GeoDataCoordinates positionOnRoute = routingModel->route().positionOnRoute();
+ emit m_parent->centerOn( positionOnRoute, false );
+ }
m_selfInteraction = false;
}