{
qDebug() << __PRETTY_FUNCTION__;
- m_mapScene->spanItems(m_zoomLevel, m_sceneCoordinate, m_viewSize);
+ m_mapScene->spanItems(currentViewSceneRect());
}
void MapEngine::getTiles(SceneCoordinate coordinate)
m_gpsLocationItem->updatePosition(SceneCoordinate(position), accuracy);
m_gpsPosition = position;
- m_mapScene->spanItems(m_zoomLevel, m_sceneCoordinate, m_viewSize);
+ m_mapScene->spanItems(currentViewSceneRect());
if (m_autoCenteringEnabled) {
m_lastAutomaticPosition = SceneCoordinate(position);
m_ownLocation->hide();
}
- m_mapScene->spanItems(m_zoomLevel, m_sceneCoordinate, m_viewSize);
+ m_mapScene->spanItems(currentViewSceneRect());
}
QGraphicsScene* MapEngine::scene()
m_mapScene->removeOutOfViewTiles(m_viewTilesGrid, m_zoomLevel);
}
- m_mapScene->spanItems(m_zoomLevel, m_sceneCoordinate, m_viewSize);
+ m_mapScene->spanItems(currentViewSceneRect());
emit newMapResolution(sceneResolution());
updateDirectionIndicator();
{
qDebug() << __PRETTY_FUNCTION__;
+ updateDirectionIndicator();
+
if (m_zoomedIn) {
m_zoomedIn = false;
m_mapScene->removeOutOfViewTiles(m_viewTilesGrid, m_zoomLevel);
m_mapScene->setZoomLevel(m_zoomLevel);
getTiles(m_sceneCoordinate);
m_mapScene->setSceneVerticalOverlap(m_viewSize.height(), m_zoomLevel);
- m_mapScene->spanItems(m_zoomLevel, m_sceneCoordinate, m_viewSize);
+ m_mapScene->spanItems(currentViewSceneRect());
emit newMapResolution(sceneResolution());
}
m_zoomLevel = zoomLevel;
}
-void MapScene::spanItems(int zoomLevel, SceneCoordinate coordinate, QSize viewSize)
+void MapScene::spanItems(QRectF viewSceneRect)
{
qDebug() << __PRETTY_FUNCTION__;
leftRect.setBottom(OSM_MAP_MAX_PIXEL_Y);
QRect rightRect = leftRect;
- // calculate current horizontal area shown on the view
- int viewSceneWidth = (1 << (OSM_MAX_ZOOM_LEVEL - zoomLevel)) * viewSize.width();
- int viewSceneLeft = coordinate.x() - viewSceneWidth / 2;
- int viewSceneRight = coordinate.x() + viewSceneWidth / 2;
-
// limit rects to include only area which really must be moved
- leftRect.setRight(-1 - (OSM_MAP_PIXELS_X - 1 - viewSceneRight));
- rightRect.setLeft(OSM_MAP_PIXELS_X + viewSceneLeft);
+ leftRect.setRight(-1 - (OSM_MAP_PIXELS_X - 1 - viewSceneRect.right()));
+ rightRect.setLeft(OSM_MAP_PIXELS_X + viewSceneRect.left());
- Q_ASSERT_X(leftRect.right() < viewSceneLeft, "spanning rect right value", "move rect is in the view area");
- Q_ASSERT_X(rightRect.left() > viewSceneRight, "spanning rect left value", "move rect is in the view area");
+ Q_ASSERT_X(leftRect.right() < viewSceneRect.left(), "spanning rect right value", "move rect is in the view area");
+ Q_ASSERT_X(rightRect.left() > viewSceneRect.right(), "spanning rect left value", "move rect is in the view area");
// move all items which intersects the rects
if (leftRect.left() < leftRect.right())
/**
* @brief Span items (others than MapTile) to opposite side of the scene
*
- * @param zoomLevel Current zoom level
- * @param coordinate Scene coordinates of the current center point
- * @param viewSize Current size of the view
+ * @param viewSceneRect Scene area which is currently drawn on the view
*/
- void spanItems(int zoomLevel, SceneCoordinate coordinate, QSize viewSize);
+ void spanItems(QRectF viewSceneRect);
/**
* @brief Save new tiles scene rect
// MAP PIXELS
/**
-* @var OMS_MAP_PIXELS_X
+* @var OSM_MAP_PIXELS_X
* @brief Amount of horizontal pixels in map
*/
const int OSM_MAP_PIXELS_X = OSM_TILES_PER_SIDE * OSM_TILE_SIZE_X;
m_direction = direction;
m_drawTriangle = draw;
+
+ update();
}