From 56d1ac7ff22f97863a9fbdd7a3ed495485c11a22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Fri, 1 Dec 2017 19:54:04 +0100 Subject: [PATCH] Fixed broken zoom handling --- src/GUI/mapview.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/GUI/mapview.cpp b/src/GUI/mapview.cpp index 2cbe37d2..ee2920ef 100644 --- a/src/GUI/mapview.cpp +++ b/src/GUI/mapview.cpp @@ -203,18 +203,23 @@ void MapView::updateWaypointsBoundingRect(const Coordinates &wp) qreal MapView::mapZoom() const { - RectC br = _tr | _rr | _wr; + RectC br; - return _map->zoomFit(viewport()->size() - QSize(2*MARGIN, 2*MARGIN), - br.isValid() ? br : RectC(_map->xy2ll(sceneRect().topLeft()), - _map->xy2ll(sceneRect().bottomRight()))); + if (_tracks.isEmpty() && _routes.isEmpty() && _waypoints.isEmpty()) + br = RectC(_map->xy2ll(sceneRect().topLeft()), + _map->xy2ll(sceneRect().bottomRight())); + else + br = _tr | _rr | _wr; + + return _map->zoomFit(viewport()->size() - QSize(2*MARGIN, 2*MARGIN), br); } QPointF MapView::contentCenter() const { - RectC br = _tr | _rr | _wr; - - return br.isValid() ? _map->ll2xy(br.center()) : sceneRect().center(); + if (_tracks.isEmpty() && _routes.isEmpty() && _waypoints.isEmpty()) + return sceneRect().center(); + else + return _map->ll2xy((_tr | _rr | _wr).center()); } void MapView::updatePOIVisibility()