diff options
author | Thiago Marcos P. Santos <thiago@mapbox.com> | 2017-01-05 14:37:10 -0200 |
---|---|---|
committer | Thiago Marcos P. Santos <tmpsantos@gmail.com> | 2017-01-05 15:09:02 -0200 |
commit | f55a6e2b7a648b61eca8da2cb4916d96ecc25ef4 (patch) | |
tree | e6230d3e165a94fcf0f99e1958fb6332119c8005 /platform/qt | |
parent | e71d9ac2d4b6cc1e6d221618c9139b64035753d9 (diff) | |
download | qtlocation-mapboxgl-f55a6e2b7a648b61eca8da2cb4916d96ecc25ef4.tar.gz |
[Qt] Expose method for changing the base API URL
Useful for redirecting to a cache server or debugging.
Diffstat (limited to 'platform/qt')
-rw-r--r-- | platform/qt/include/qmapboxgl.hpp | 4 | ||||
-rw-r--r-- | platform/qt/src/qmapboxgl.cpp | 23 |
2 files changed, 27 insertions, 0 deletions
diff --git a/platform/qt/include/qmapboxgl.hpp b/platform/qt/include/qmapboxgl.hpp index c3a83610be..c957ce586b 100644 --- a/platform/qt/include/qmapboxgl.hpp +++ b/platform/qt/include/qmapboxgl.hpp @@ -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 { diff --git a/platform/qt/src/qmapboxgl.cpp b/platform/qt/src/qmapboxgl.cpp index 1f5638337f..398b31684a 100644 --- a/platform/qt/src/qmapboxgl.cpp +++ b/platform/qt/src/qmapboxgl.cpp @@ -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) { } @@ -349,6 +350,26 @@ void QMapboxGLSettings::setAccessToken(const QString &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); |