MapboxMapProvider.cpp 936 Bytes
Newer Older
Pierre TILAK's avatar
Pierre TILAK committed
1 2 3 4 5
#include "MapboxMapProvider.h"
#include "QGCApplication.h"
#include "QGCMapEngine.h"
#include "SettingsManager.h"

Cosmin Marc's avatar
Cosmin Marc committed
6 7 8 9 10 11
static const QString MapBoxUrl = QStringLiteral("https://api.mapbox.com/v4/%1/%2/%3/%4.jpg80?access_token=%5");

MapboxMapProvider::MapboxMapProvider(const QString &mapName, const quint32 averageSize, const QGeoMapType::MapStyle mapType, QObject* parent)
    : MapProvider(QStringLiteral("https://www.mapbox.com/"), QStringLiteral("jpg"), averageSize, mapType, parent)
    , _mapboxName(mapName)
{
Pierre TILAK's avatar
Pierre TILAK committed
12 13
}

Cosmin Marc's avatar
Cosmin Marc committed
14 15 16
QString MapboxMapProvider::_getURL(const int x, const int y, const int zoom, QNetworkAccessManager* networkManager) {
    Q_UNUSED(networkManager)
    const QString mapBoxToken = qgcApp()->toolbox()->settingsManager()->appSettings()->mapboxToken()->rawValue().toString();
Pierre TILAK's avatar
Pierre TILAK committed
17
    if (!mapBoxToken.isEmpty()) {
Cosmin Marc's avatar
Cosmin Marc committed
18
        return MapBoxUrl.arg(_mapboxName).arg(zoom).arg(x).arg(y).arg(mapBoxToken);
Pierre TILAK's avatar
Pierre TILAK committed
19
    }
Cosmin Marc's avatar
Cosmin Marc committed
20
    return QString();
Pierre TILAK's avatar
Pierre TILAK committed
21
}