Skip to content

Commit

Permalink
PS-1039 - Mapbox attribution displayed
Browse files Browse the repository at this point in the history
  • Loading branch information
edupazpix4d committed Oct 27, 2021
1 parent 8e3bb8f commit 93cd442
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 2 deletions.
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);
}

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

0 comments on commit 93cd442

Please sign in to comment.