Commit 27fc53e5 authored by Sanjiban Bairagya's avatar Sanjiban Bairagya Committed by Sanjiban Bairagya

Place the current-location marker on a point on the route itself,

when it is very near to the route.
parent d2c3d515
......@@ -23,6 +23,7 @@ Item {
property var snappedPositionMarkerScreenPosition: null
property bool guidanceMode: false
property double screenAccuracy: 0
property alias deviated: navigation.deviated
onGuidanceModeChanged: {
if (guidanceMode && marbleItem) {
......@@ -150,7 +151,11 @@ Item {
function updateItem()
{
if (navigation.marbleQuickItem) {
root.snappedPositionMarkerScreenPosition = navigation.positionOnRoute();
if (navigation.deviated){
root.snappedPositionMarkerScreenPosition = navigation.currentPosition();
} else {
root.snappedPositionMarkerScreenPosition = navigation.positionOnRoute();
}
root.screenAccuracy = navigation.screenAccuracy();
}
else
......
......@@ -286,6 +286,15 @@ QPointF Navigation::positionOnRoute() const
return QPointF(x,y);
}
QPointF Navigation::currentPosition() const
{
GeoDataCoordinates coordinates = d->model()->positionTracking()->currentLocation();
qreal x = 0;
qreal y = 0;
d->m_marbleQuickItem->map()->viewport()->screenCoordinates(coordinates, x, y);
return QPointF(x,y);
}
double Navigation::screenAccuracy() const
{
double distanceMeter = d->model()->positionTracking()->accuracy().horizontal;
......@@ -322,6 +331,8 @@ void Navigation::setMarbleQuickItem(Marble::MarbleQuickItem *marbleQuickItem)
d->model()->routingManager()->setShowGuidanceModeStartupWarning( false );
connect( d->model()->routingManager()->routingModel(),
SIGNAL(positionChanged()), this, SLOT(update()) );
connect( d->model()->routingManager()->routingModel(),
SIGNAL(deviatedFromRoute(bool)), this, SIGNAL(deviationChanged()) );
delete d->m_autoNavigation;
d->m_autoNavigation = new Marble::AutoNavigation( d->model(), d->m_marbleQuickItem->map()->viewport(), this );
......@@ -336,6 +347,7 @@ void Navigation::setMarbleQuickItem(Marble::MarbleQuickItem *marbleQuickItem)
d->m_autoNavigation, SLOT(inhibitAutoAdjustments()) );
connect( d->model()->positionTracking(), SIGNAL(statusChanged(PositionProviderStatus)),
&d->m_voiceNavigation, SLOT(handleTrackingStatusChange(PositionProviderStatus)) );
}
emit marbleQuickItemChanged(marbleQuickItem);
}
......
......@@ -87,6 +87,8 @@ public:
Q_INVOKABLE double screenAccuracy() const;
Q_INVOKABLE QPointF currentPosition() const;
public Q_SLOTS:
void setMarbleQuickItem(Marble::MarbleQuickItem * marbleQuickItem);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment