Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework style settings and make QMapLibre::Settings more future-proof #57

Merged
merged 1 commit into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/quick/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Window {
name: "maplibre"
// specify plugin parameters if necessary
PluginParameter {
name: "maplibre.map.style_urls"
name: "maplibre.map.styles"
value: "https://demotiles.maplibre.org/style.json"
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ target_sources(
renderer_backend.cpp renderer_backend_p.hpp
renderer_observer_p.hpp
scheduler.cpp scheduler_p.hpp
settings.cpp
settings.cpp settings_p.hpp
types.cpp
utils.cpp
)
Expand Down
22 changes: 8 additions & 14 deletions src/core/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,17 @@ mbgl::MapOptions mapOptionsFromSettings(const QMapLibre::Settings &settings, con
}

mbgl::ResourceOptions resourceOptionsFromSettings(const QMapLibre::Settings &settings) {
if (settings.tileServerOptions() == nullptr) {
return std::move(mbgl::ResourceOptions()
.withAssetPath(settings.assetPath().toStdString())
.withCachePath(settings.cacheDatabasePath().toStdString())
.withMaximumCacheSize(settings.cacheDatabaseMaximumSize()));
}

return std::move(mbgl::ResourceOptions()
.withApiKey(settings.apiKey().toStdString())
.withAssetPath(settings.assetPath().toStdString())
.withTileServerOptions(*settings.tileServerOptionsInternal())
.withTileServerOptions(*settings.tileServerOptions())
.withCachePath(settings.cacheDatabasePath().toStdString())
.withMaximumCacheSize(settings.cacheDatabaseMaximumSize()));
}
Expand Down Expand Up @@ -1236,14 +1243,6 @@ void Map::connectionEstablished() {
mbgl::NetworkStatus::Reachable();
}

/*!
Returns a list containing a pair of string objects, representing the style
URL and name, respectively.
*/
const QVector<QPair<QString, QString>> &Map::defaultStyles() const {
return d_ptr->defaultStyles;
}

/*!
\fn void QMapLibre::Map::needsRendering()

Expand Down Expand Up @@ -1303,11 +1302,6 @@ MapPrivate::MapPrivate(Map *q, const Settings &settings, const QSize &size, qrea
connect(m_mapObserver.get(), &MapObserver::copyrightsChanged, q, &Map::copyrightsChanged);

auto resourceOptions = resourceOptionsFromSettings(settings);
for (auto style : resourceOptions.tileServerOptions().defaultStyles()) {
defaultStyles.append(
QPair<QString, QString>(QString::fromStdString(style.getUrl()), QString::fromStdString(style.getName())));
}

auto clientOptions = clientOptionsFromSettings(settings);

// Setup the Map object.
Expand Down
2 changes: 0 additions & 2 deletions src/core/map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,6 @@ class Q_MAPLIBRE_CORE_EXPORT Map : public QObject {
void destroyRenderer();
void setFramebufferObject(quint32 fbo, const QSize &size);

const QVector<QPair<QString, QString>> &defaultStyles() const;

public slots:
void render();
void connectionEstablished();
Expand Down
1 change: 0 additions & 1 deletion src/core/map_p.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ class MapPrivate : public QObject, public mbgl::RendererFrontend {

mbgl::EdgeInsets margins;
std::unique_ptr<mbgl::Map> mapObj{};
QVector<QPair<QString, QString>> defaultStyles;

public slots:
void requestRendering();
Expand Down
Loading