[Qt] Expose method for changing the base API URL
Useful for redirecting to a cache server or debugging.
This commit is contained in:
committed by
Thiago Marcos P. Santos
parent
e71d9ac2d4
commit
f55a6e2b7a
@@ -60,6 +60,9 @@ public:
|
||||
QString accessToken() const;
|
||||
void setAccessToken(const QString &);
|
||||
|
||||
QString apiBaseUrl() const;
|
||||
void setApiBaseUrl(const QString &);
|
||||
|
||||
private:
|
||||
GLContextMode m_contextMode;
|
||||
ConstrainMode m_constrainMode;
|
||||
@@ -69,6 +72,7 @@ private:
|
||||
QString m_cacheDatabasePath;
|
||||
QString m_assetPath;
|
||||
QString m_accessToken;
|
||||
QString m_apiBaseUrl;
|
||||
};
|
||||
|
||||
struct Q_DECL_EXPORT QMapboxGLCameraOptions {
|
||||
|
||||
@@ -196,6 +196,7 @@ QMapboxGLSettings::QMapboxGLSettings()
|
||||
, m_cacheDatabasePath(":memory:")
|
||||
, m_assetPath(QCoreApplication::applicationDirPath())
|
||||
, m_accessToken(qgetenv("MAPBOX_ACCESS_TOKEN"))
|
||||
, m_apiBaseUrl(mbgl::util::API_BASE_URL)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -348,6 +349,26 @@ void QMapboxGLSettings::setAccessToken(const QString &token)
|
||||
m_accessToken = token;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the API base URL.
|
||||
*/
|
||||
QString QMapboxGLSettings::apiBaseUrl() const
|
||||
{
|
||||
return m_apiBaseUrl;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the API base \a url.
|
||||
|
||||
The API base URL is the URL that the \b "mapbox://" protocol will
|
||||
be resolved to. It defaults to "https://api.mapbox.com" but can be
|
||||
changed, for instance, to a tile cache server address.
|
||||
*/
|
||||
void QMapboxGLSettings::setApiBaseUrl(const QString& url)
|
||||
{
|
||||
m_apiBaseUrl = url;
|
||||
}
|
||||
|
||||
/*!
|
||||
\class QMapboxGL
|
||||
\brief The QMapboxGL class is a Qt wrapper for the Mapbox GL Native engine.
|
||||
@@ -1125,6 +1146,8 @@ QMapboxGLPrivate::QMapboxGLPrivate(QMapboxGL *q, const QMapboxGLSettings &settin
|
||||
qRegisterMetaType<QMapboxGL::MapChange>("QMapboxGL::MapChange");
|
||||
|
||||
fileSourceObj->setAccessToken(settings.accessToken().toStdString());
|
||||
fileSourceObj->setAPIBaseURL(settings.apiBaseUrl().toStdString());
|
||||
|
||||
connect(this, SIGNAL(needsRendering()), q_ptr, SIGNAL(needsRendering()), Qt::QueuedConnection);
|
||||
connect(this, SIGNAL(mapChanged(QMapboxGL::MapChange)), q_ptr, SIGNAL(mapChanged(QMapboxGL::MapChange)), Qt::QueuedConnection);
|
||||
connect(this, SIGNAL(copyrightsChanged(QString)), q_ptr, SIGNAL(copyrightsChanged(QString)), Qt::QueuedConnection);
|
||||
|
||||
Reference in New Issue
Block a user