QMapboxGLSettings Class

The QMapboxGLSettings class stores the initial configuration for QMapboxGL. More...

Header: #include <QMapboxGLSettings>
Since: Qt 4.7

Public Types

enum ConstrainMode { NoConstrain, ConstrainHeightOnly, ConstrainWidthAndHeight }
enum GLContextMode { UniqueGLContext, SharedGLContext }
enum ViewportMode { DefaultViewport, FlippedYViewport }

Public Functions

QMapboxGLSettings()
QString accessToken() const
QString apiBaseUrl() const
QString assetPath() const
unsigned cacheDatabaseMaximumSize() const
QString cacheDatabasePath() const
ConstrainMode constrainMode() const
GLContextMode contextMode() const
void setAccessToken(const QString &token)
void setApiBaseUrl(const QString &url)
void setAssetPath(const QString &path)
void setCacheDatabaseMaximumSize(unsigned size)
void setCacheDatabasePath(const QString &path)
void setConstrainMode(ConstrainMode mode)
void setContextMode(GLContextMode mode)
void setViewportMode(ViewportMode mode)
ViewportMode viewportMode() const

Detailed Description

The QMapboxGLSettings class stores the initial configuration for QMapboxGL.

QMapboxGLSettings is used to configure QMapboxGL at the moment of its creation. Once created, the QMapboxGLSettings of a QMapboxGL can no longer be changed.

Member Type Documentation

enum QMapboxGLSettings::ConstrainMode

This enum determines if the map wraps.

ConstantValueDescription
QMapboxGLSettings::NoConstrain0The map will wrap on the horizontal axis. Since it doesn't make sense to wrap on the vertical axis in a Web Mercator projection, the map will scroll and show some empty space.
QMapboxGLSettings::ConstrainHeightOnly1The map will wrap around the horizontal axis, like a spinning globe. This is the recommended constrain mode.
QMapboxGLSettings::ConstrainWidthAndHeight2The map won't wrap and panning is restricted to the boundaries of the map.

See also constrainMode().

enum QMapboxGLSettings::GLContextMode

This enum sets the expectations for the OpenGL state.

ConstantValueDescription
QMapboxGLSettings::UniqueGLContext0The OpenGL context is only used by QMapboxGL, so it is not reset before each rendering. Use this mode if the intention is to only draw a fullscreen map.
QMapboxGLSettings::SharedGLContext1The OpenGL context is shared and the state will be restored before rendering. This mode is safer when OpenGL calls are performed prior of after we call QMapboxGL::render for rendering a map.

See also contextMode().

enum QMapboxGLSettings::ViewportMode

This enum flips the map vertically.

ConstantValueDescription
QMapboxGLSettings::DefaultViewport0Native orientation.
QMapboxGLSettings::FlippedYViewport1Mirrored vertically.

See also viewportMode().

Member Function Documentation

QMapboxGLSettings::QMapboxGLSettings()

Constructs a QMapboxGLSettings object with the default values. The default configuration is valid for initializing a QMapboxGL.

QString QMapboxGLSettings::accessToken() const

Returns the access token.

By default, it is taken from the environment variable MAPBOX_ACCESS_TOKEN or empty if the variable is not set.

See also setAccessToken().

QString QMapboxGLSettings::apiBaseUrl() const

Returns the API base URL.

See also setApiBaseUrl().

QString QMapboxGLSettings::assetPath() const

Returns the asset path, which is the root directory from where the asset:// scheme gets resolved in a style. asset:// can be used for loading a resource from the disk in a style rather than fetching it from the network.

By default, it is set to the value returned by QCoreApplication::applicationDirPath().

See also setAssetPath().

unsigned QMapboxGLSettings::cacheDatabaseMaximumSize() const

Returns the cache database maximum hard size in bytes. The database will grow until the limit is reached. Setting a maximum size smaller than the current size of an existing database results in undefined behavior

By default, it is set to 50 MB.

See also setCacheDatabaseMaximumSize().

QString QMapboxGLSettings::cacheDatabasePath() const

Returns the cache database path. The cache is used for storing recently used resources like tiles and also an offline tile database pre-populated by the Offline Tool.

By default, it is set to :memory: meaning it will create an in-memory cache instead of a file on disk.

See also setCacheDatabasePath().

ConstrainMode QMapboxGLSettings::constrainMode() const

Returns the constrain mode. This is used to limit the map to wrap around the globe horizontally.

By default, it is set to QMapboxGLSettings::ConstrainHeightOnly.

See also setConstrainMode().

GLContextMode QMapboxGLSettings::contextMode() const

Returns the OpenGL context mode. This is specially important when mixing with other OpenGL draw calls.

By default, it is set to QMapboxGLSettings::SharedGLContext.

See also setContextMode().

void QMapboxGLSettings::setAccessToken(const QString &token)

Sets the access token.

Mapbox-hosted vector tiles and styles require an API access token, which you can obtain from the Mapbox account page. Access tokens associate requests to Mapbox's vector tile and style APIs with your Mapbox account. They also deter other developers from using your styles without your permission.

See also accessToken().

void QMapboxGLSettings::setApiBaseUrl(const QString &url)

Sets the API base url.

The API base URL is the URL that the "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.

See also apiBaseUrl().

void QMapboxGLSettings::setAssetPath(const QString &path)

Sets the asset path.

See also assetPath().

void QMapboxGLSettings::setCacheDatabaseMaximumSize(unsigned size)

Returns the maximum allowed cache database size in bytes.

See also cacheDatabaseMaximumSize().

void QMapboxGLSettings::setCacheDatabasePath(const QString &path)

Sets the cache database path.

Setting the path to :memory: will create an in-memory cache.

See also cacheDatabasePath().

void QMapboxGLSettings::setConstrainMode(ConstrainMode mode)

Sets the map constrain mode.

See also constrainMode().

void QMapboxGLSettings::setContextMode(GLContextMode mode)

Sets the OpenGL context mode.

See also contextMode().

void QMapboxGLSettings::setViewportMode(ViewportMode mode)

Sets the viewport mode.

See also viewportMode().

ViewportMode QMapboxGLSettings::viewportMode() const

Returns the viewport mode. This is used to flip the vertical orientation of the map as some devices may use inverted orientation.

By default, it is set to QMapboxGLSettings::DefaultViewport.

See also setViewportMode().