diff --git a/src/GUI/mapview.cpp b/src/GUI/mapview.cpp index 60a32a04..4d10a663 100644 --- a/src/GUI/mapview.cpp +++ b/src/GUI/mapview.cpp @@ -274,6 +274,7 @@ void MapView::setMap(Map *map) _map = map; _map->load(); + _map->setBackgroundColor(_backgroundColor); connect(_map, SIGNAL(loaded()), this, SLOT(reloadMap())); digitalZoom(0); diff --git a/src/map/offlinemap.cpp b/src/map/offlinemap.cpp index 97e3499d..0491030b 100644 --- a/src/map/offlinemap.cpp +++ b/src/map/offlinemap.cpp @@ -622,12 +622,17 @@ void OfflineMap::drawImage(QPainter *painter, const QRectF &rect) void OfflineMap::draw(QPainter *painter, const QRectF &rect) { + QRectF ir = rect.intersected(bounds()); + + if (ir != rect) + painter->fillRect(rect, _backgroundColor); + if (_ozf.isOpen()) - drawOZF(painter, rect); + drawOZF(painter, ir); else if (_tileSize.isValid()) - drawTiled(painter, rect); + drawTiled(painter, ir); else - drawImage(painter, rect); + drawImage(painter, ir); } QPointF OfflineMap::ll2xy(const Coordinates &c) diff --git a/src/map/onlinemap.cpp b/src/map/onlinemap.cpp index 8f10df9f..ccfd0e7e 100644 --- a/src/map/onlinemap.cpp +++ b/src/map/onlinemap.cpp @@ -228,14 +228,18 @@ qreal OnlineMap::zoomOut() void OnlineMap::draw(QPainter *painter, const QRectF &rect) { qreal scale = zoom2scale(_zoom); + QRectF ir = rect.intersected(bounds()); - QPoint tile = mercator2tile(QPointF(rect.topLeft().x() * scale, - -rect.topLeft().y() * scale), _zoom); - QPoint tl = QPoint((int)floor(rect.left() / (qreal)TILE_SIZE) - * TILE_SIZE, (int)floor(rect.top() / TILE_SIZE) * TILE_SIZE); + if (ir != rect) + painter->fillRect(rect, _backgroundColor); + + QPoint tile = mercator2tile(QPointF(ir.topLeft().x() * scale, + -ir.topLeft().y() * scale), _zoom); + QPoint tl = QPoint((int)floor(ir.left() / (qreal)TILE_SIZE) + * TILE_SIZE, (int)floor(ir.top() / TILE_SIZE) * TILE_SIZE); QList tiles; - QSizeF s(rect.right() - tl.x(), rect.bottom() - tl.y()); + QSizeF s(ir.right() - tl.x(), ir.bottom() - tl.y()); for (int i = 0; i < ceil(s.width() / TILE_SIZE); i++) for (int j = 0; j < ceil(s.height() / TILE_SIZE); j++) tiles.append(Tile(QPoint(tile.x() + i, tile.y() + j), _zoom));