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

Draft - PS-1039 - Mapbox attribution displayed #7

Draft
wants to merge 1 commit into
base: stable/1.1.1
Choose a base branch
from
Draft
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
Binary file added res/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions res/mapbox.qrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/mapbox">
<file>logo.png</file>
</qresource>
</RCC>
25 changes: 24 additions & 1 deletion src/GeoTiledMappingManagerEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,33 @@ GeoTiledMappingManagerEngine::GeoTiledMappingManagerEngine(const QVariantMap& pa

QGeoMap* GeoTiledMappingManagerEngine::createMap()
{
return m_noMapTiles ? new NoGeoTiledMap(this, 0) : new QGeoTiledMap(this, 0);
return m_noMapTiles ? new NoGeoTiledMap(this, 0) : new CustomGeoTiledMap(this, 0);
}

QSGNode* NoGeoTiledMap::updateSceneGraph(QSGNode*, QQuickWindow*)
{
return nullptr;
}

CustomGeoTiledMap::CustomGeoTiledMap(GeoTiledMappingManagerEngine *engine, QObject *parent) :
QGeoTiledMap(engine, parent) {
setCopyrightVisible(true);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be something you don't want to display if you use custom_urls, right? @viktor-kopp-pix4d @aleksandr-levin-pix4d

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, for custom tile providers it does not make sense to show Mapbox's logo

}

QString CustomGeoTiledMap::copyrightsStyleSheet() const
{
return QStringLiteral("* { vertical-align: middle; font-weight: normal }");
}

void CustomGeoTiledMap::evaluateCopyrights(const QSet<QGeoTileSpec> &visibleTiles) {
Q_UNUSED(visibleTiles);

QString copyrightsHtmlFinal("© <a href='https://www.mapbox.com/about/maps/'>Mapbox</a> "
"© <a href='http://www.openstreetmap.org/copyright'>OpenStreetMap</a> "
"<strong><a href='https://www.mapbox.com/map-feedback/' target='_blank'>Improve this map</a></strong>");

copyrightsHtmlFinal = "<table><tr><th><img src='qrc:/mapboxgl/logo.png'/></th><th>"
+ copyrightsHtmlFinal + "</th></tr></table>";

emit copyrightsChanged(copyrightsHtmlFinal);
}
8 changes: 8 additions & 0 deletions src/GeoTiledMappingManagerEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ class NoGeoTiledMap : public QGeoTiledMap
QSGNode* updateSceneGraph(QSGNode*, QQuickWindow* window) override;
};

class CustomGeoTiledMap: public QGeoTiledMap {
public:
CustomGeoTiledMap(GeoTiledMappingManagerEngine *engine, QObject *parent);
virtual ~CustomGeoTiledMap() = default;
QString copyrightsStyleSheet() const override;
virtual void evaluateCopyrights(const QSet<QGeoTileSpec> &visibleTiles) override;
};

class GeoTiledMappingManagerEngine : public QGeoTiledMappingManagerEngine
{
Q_OBJECT
Expand Down
4 changes: 3 additions & 1 deletion test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ find_package(Qt5 COMPONENTS
REQUIRED QUIET)
find_package(QtBasemapPlugin REQUIRED QUIET)

add_executable(example example.cpp)
qt5_add_resources(IMAGES_RCC "res/mapbox.qrc")

add_executable(example example.cpp ${IMAGES_RCC})
get_property(MAP_PLUGIN TARGET qtgeoservices_basemap_pix4d PROPERTY IMPORTED_LOCATION_RELEASE)
message(STATUS "Map plugin path ${MAP_PLUGIN}")

Expand Down