diff --git a/qgcresources.qrc b/qgcresources.qrc
index 977a849..49a66a1 100644
--- a/qgcresources.qrc
+++ b/qgcresources.qrc
@@ -22,6 +22,7 @@
resources/gear-black.svg
resources/gear-white.svg
resources/helicoptericon.svg
+ resources/BingNoTileBytes.dat
resources/JoystickBezel.png
resources/JoystickBezelLight.png
resources/land.svg
diff --git a/resources/BingNoTileBytes.dat b/resources/BingNoTileBytes.dat
new file mode 100644
index 0000000..fa081a5
Binary files /dev/null and b/resources/BingNoTileBytes.dat differ
diff --git a/src/QtLocationPlugin/QGCMapEngine.cpp b/src/QtLocationPlugin/QGCMapEngine.cpp
index 15774db..45577d1 100644
--- a/src/QtLocationPlugin/QGCMapEngine.cpp
+++ b/src/QtLocationPlugin/QGCMapEngine.cpp
@@ -222,6 +222,15 @@ QGCMapEngine::cacheTile(QString type, const QString& hash, const QByteArray& ima
QString
QGCMapEngine::getTileHash(QString type, int x, int y, int z)
{
+#if 0
+ int maxCachedZoom = 15;
+ if (z > maxCachedZoom) {
+ double unZoomFactor = qPow(2, z - maxCachedZoom);
+ x = (double)x / unZoomFactor;
+ y = (double)y / unZoomFactor;
+ z = maxCachedZoom;
+ }
+#endif
return QString::asprintf("%010d%08d%08d%03d", getQGCMapEngine()->urlFactory()->getIdFromType(type), x, y, z);
}
diff --git a/src/QtLocationPlugin/QGCMapUrlEngine.h b/src/QtLocationPlugin/QGCMapUrlEngine.h
index 769a3c4..6809926 100644
--- a/src/QtLocationPlugin/QGCMapUrlEngine.h
+++ b/src/QtLocationPlugin/QGCMapUrlEngine.h
@@ -24,7 +24,7 @@
#include "MapboxMapProvider.h"
#include "ElevationMapProvider.h"
-#define MAX_MAP_ZOOM (20.0)
+#define MAX_MAP_ZOOM (23.0)
class UrlFactory : public QObject {
Q_OBJECT
diff --git a/src/QtLocationPlugin/QGeoMapReplyQGC.cpp b/src/QtLocationPlugin/QGeoMapReplyQGC.cpp
index 7f37010..557d144 100644
--- a/src/QtLocationPlugin/QGeoMapReplyQGC.cpp
+++ b/src/QtLocationPlugin/QGeoMapReplyQGC.cpp
@@ -53,7 +53,8 @@
#include
#include "TerrainTile.h"
-int QGeoTiledMapReplyQGC::_requestCount = 0;
+int QGeoTiledMapReplyQGC::_requestCount = 0;
+QByteArray QGeoTiledMapReplyQGC::_bingNoTileImage;
//-----------------------------------------------------------------------------
QGeoTiledMapReplyQGC::QGeoTiledMapReplyQGC(QNetworkAccessManager *networkManager, const QNetworkRequest &request, const QGeoTileSpec &spec, QObject *parent)
@@ -62,6 +63,12 @@ QGeoTiledMapReplyQGC::QGeoTiledMapReplyQGC(QNetworkAccessManager *networkManager
, _request(request)
, _networkManager(networkManager)
{
+ if (_bingNoTileImage.count() == 0) {
+ QFile file(":/res/BingNoTileBytes.dat");
+ file.open(QFile::ReadOnly);
+ _bingNoTileImage = file.readAll();
+ file.close();
+ }
if(_request.url().isEmpty()) {
if(!_badMapbox.size()) {
QFile b(":/res/notile.png");
@@ -135,11 +142,19 @@ QGeoTiledMapReplyQGC::networkReplyFinished()
}
emit terrainDone(a, QNetworkReply::NoError);
} else {
- //-- This is a map tile. Process and cache it if valid.
- setMapImageData(a);
- if(!format.isEmpty()) {
- setMapImageFormat(format);
- getQGCMapEngine()->cacheTile(getQGCMapEngine()->urlFactory()->getTypeFromId(tileSpec().mapId()), tileSpec().x(), tileSpec().y(), tileSpec().zoom(), a, format);
+ if (a == _bingNoTileImage) {
+ // Bing doesn't return an error if you request a tile above supported zoom level
+ // It instead returns an image of a missing tile graphic. We need to detect that
+ // and error out so Qt will deal with zooming correctly even if it doesn't have the tile.
+ // This allows us to zoom up to level 23 even though the tiles don't actually exist
+ setError(QGeoTiledMapReply::CommunicationError, "Bing tile above zoom level");
+ } else {
+ //-- This is a map tile. Process and cache it if valid.
+ setMapImageData(a);
+ if(!format.isEmpty()) {
+ setMapImageFormat(format);
+ getQGCMapEngine()->cacheTile(getQGCMapEngine()->urlFactory()->getTypeFromId(tileSpec().mapId()), tileSpec().x(), tileSpec().y(), tileSpec().zoom(), a, format);
+ }
}
setFinished(true);
}
diff --git a/src/QtLocationPlugin/QGeoMapReplyQGC.h b/src/QtLocationPlugin/QGeoMapReplyQGC.h
index 58a59a0..af9ab1e 100644
--- a/src/QtLocationPlugin/QGeoMapReplyQGC.h
+++ b/src/QtLocationPlugin/QGeoMapReplyQGC.h
@@ -81,6 +81,7 @@ private:
QByteArray _badMapbox;
QByteArray _badTile;
QTimer _timer;
+ static QByteArray _bingNoTileImage;
static int _requestCount;
};