Skip to content

Commit 93cd442

Browse files
committed
PS-1039 - Mapbox attribution displayed
1 parent 8e3bb8f commit 93cd442

File tree

5 files changed

+40
-2
lines changed

5 files changed

+40
-2
lines changed

res/logo.png

2.68 KB
Loading

res/mapbox.qrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<RCC>
2+
<qresource prefix="/mapbox">
3+
<file>logo.png</file>
4+
</qresource>
5+
</RCC>

src/GeoTiledMappingManagerEngine.cpp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,33 @@ GeoTiledMappingManagerEngine::GeoTiledMappingManagerEngine(const QVariantMap& pa
168168

169169
QGeoMap* GeoTiledMappingManagerEngine::createMap()
170170
{
171-
return m_noMapTiles ? new NoGeoTiledMap(this, 0) : new QGeoTiledMap(this, 0);
171+
return m_noMapTiles ? new NoGeoTiledMap(this, 0) : new CustomGeoTiledMap(this, 0);
172172
}
173173

174174
QSGNode* NoGeoTiledMap::updateSceneGraph(QSGNode*, QQuickWindow*)
175175
{
176176
return nullptr;
177177
}
178+
179+
CustomGeoTiledMap::CustomGeoTiledMap(GeoTiledMappingManagerEngine *engine, QObject *parent) :
180+
QGeoTiledMap(engine, parent) {
181+
setCopyrightVisible(true);
182+
}
183+
184+
QString CustomGeoTiledMap::copyrightsStyleSheet() const
185+
{
186+
return QStringLiteral("* { vertical-align: middle; font-weight: normal }");
187+
}
188+
189+
void CustomGeoTiledMap::evaluateCopyrights(const QSet<QGeoTileSpec> &visibleTiles) {
190+
Q_UNUSED(visibleTiles);
191+
192+
QString copyrightsHtmlFinal("© <a href='https://www.mapbox.com/about/maps/'>Mapbox</a> "
193+
"© <a href='http://www.openstreetmap.org/copyright'>OpenStreetMap</a> "
194+
"<strong><a href='https://www.mapbox.com/map-feedback/' target='_blank'>Improve this map</a></strong>");
195+
196+
copyrightsHtmlFinal = "<table><tr><th><img src='qrc:/mapboxgl/logo.png'/></th><th>"
197+
+ copyrightsHtmlFinal + "</th></tr></table>";
198+
199+
emit copyrightsChanged(copyrightsHtmlFinal);
200+
}

src/GeoTiledMappingManagerEngine.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ class NoGeoTiledMap : public QGeoTiledMap
1111
QSGNode* updateSceneGraph(QSGNode*, QQuickWindow* window) override;
1212
};
1313

14+
class CustomGeoTiledMap: public QGeoTiledMap {
15+
public:
16+
CustomGeoTiledMap(GeoTiledMappingManagerEngine *engine, QObject *parent);
17+
virtual ~CustomGeoTiledMap() = default;
18+
QString copyrightsStyleSheet() const override;
19+
virtual void evaluateCopyrights(const QSet<QGeoTileSpec> &visibleTiles) override;
20+
};
21+
1422
class GeoTiledMappingManagerEngine : public QGeoTiledMappingManagerEngine
1523
{
1624
Q_OBJECT

test_package/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ find_package(Qt5 COMPONENTS
1717
REQUIRED QUIET)
1818
find_package(QtBasemapPlugin REQUIRED QUIET)
1919

20-
add_executable(example example.cpp)
20+
qt5_add_resources(IMAGES_RCC "res/mapbox.qrc")
21+
22+
add_executable(example example.cpp ${IMAGES_RCC})
2123
get_property(MAP_PLUGIN TARGET qtgeoservices_basemap_pix4d PROPERTY IMPORTED_LOCATION_RELEASE)
2224
message(STATUS "Map plugin path ${MAP_PLUGIN}")
2325

0 commit comments

Comments
 (0)