diff options
author | Paolo Angelelli <paolo.angelelli@qt.io> | 2017-09-21 18:14:26 +0200 |
---|---|---|
committer | Paolo Angelelli <paolo.angelelli@qt.io> | 2018-01-27 09:56:25 +0000 |
commit | 69a42c4a5c37a5a74c4b285c64328bc88ed8e059 (patch) | |
tree | 54c3d5bf14a4938ab4786d5dfb70379aeee2894d /src/plugins/geoservices/mapboxgl | |
parent | a6ff21e1e5ae264b7de264b47e08d334739fa4c6 (diff) | |
download | qtlocation-69a42c4a5c37a5a74c4b285c64328bc88ed8e059.tar.gz |
Allow plugins to use alternative map projections
QtLocation mapping has always been geared around the WebMercator
projection. Some mapping SDKs support additional projections, such
as General Perspective (often called globe view or globe rendering).
The goal of this patch is to allow a plugin to provide such a view,
disabling WebMercator specific features, and redirecting API calls
to plugin-specific implementations.
In particular, this patch disables the rendering of Map Items
(QDeclarativeGeoMapItemBase and sons) for projections different from
WebMercator, with the exception of MapQuickItems.
MapQuickItems, in turn, lose the ability to draw "on the map", when
the projection is different from WebMercator. However, they can still
be used to add geolocated popups, buttons and other UI elements.
fitViewportToMapItems is also disabled, for both it can't be computed
and there wouldn't be any item to fit (with the exception of
mapquickitems)
Change-Id: I9fa2fdd01a35a078fc4663efc9d269c4ecaa3f41
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src/plugins/geoservices/mapboxgl')
-rw-r--r-- | src/plugins/geoservices/mapboxgl/qgeomapmapboxgl.cpp | 7 | ||||
-rw-r--r-- | src/plugins/geoservices/mapboxgl/qgeomapmapboxgl.h | 1 | ||||
-rw-r--r-- | src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp | 6 |
3 files changed, 11 insertions, 3 deletions
diff --git a/src/plugins/geoservices/mapboxgl/qgeomapmapboxgl.cpp b/src/plugins/geoservices/mapboxgl/qgeomapmapboxgl.cpp index dd5c9a86..c04aa5e3 100644 --- a/src/plugins/geoservices/mapboxgl/qgeomapmapboxgl.cpp +++ b/src/plugins/geoservices/mapboxgl/qgeomapmapboxgl.cpp @@ -372,6 +372,13 @@ void QGeoMapMapboxGL::setMapItemsBefore(const QString &before) d->m_mapItemsBefore = before; } +QGeoMap::Capabilities QGeoMapMapboxGL::capabilities() const +{ + return Capabilities(SupportsVisibleRegion + | SupportsSetBearing + | SupportsAnchoringCoordinate); +} + QSGNode *QGeoMapMapboxGL::updateSceneGraph(QSGNode *oldNode, QQuickWindow *window) { Q_D(QGeoMapMapboxGL); diff --git a/src/plugins/geoservices/mapboxgl/qgeomapmapboxgl.h b/src/plugins/geoservices/mapboxgl/qgeomapmapboxgl.h index 73cfd75a..df76fcab 100644 --- a/src/plugins/geoservices/mapboxgl/qgeomapmapboxgl.h +++ b/src/plugins/geoservices/mapboxgl/qgeomapmapboxgl.h @@ -57,6 +57,7 @@ public: void setMapboxGLSettings(const QMapboxGLSettings &); void setUseFBO(bool); void setMapItemsBefore(const QString &); + Capabilities capabilities() const override; private Q_SLOTS: // QMapboxGL diff --git a/src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp b/src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp index f39bfae3..4835c201 100644 --- a/src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp +++ b/src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp @@ -89,18 +89,18 @@ QMapbox::Feature featureFromMapRectangle(QDeclarativeRectangleMapItem *mapItem) QMapbox::Feature featureFromMapCircle(QDeclarativeCircleMapItem *mapItem) { static const int circleSamples = 128; - + const QGeoProjectionWebMercator &p = static_cast<const QGeoProjectionWebMercator&>(mapItem->map()->geoProjection()); QList<QGeoCoordinate> path; QGeoCoordinate leftBound; QDeclarativeCircleMapItem::calculatePeripheralPoints(path, mapItem->center(), mapItem->radius(), circleSamples, leftBound); QList<QDoubleVector2D> pathProjected; for (const QGeoCoordinate &c : qAsConst(path)) - pathProjected << mapItem->map()->geoProjection().geoToMapProjection(c); + pathProjected << p.geoToMapProjection(c); if (QDeclarativeCircleMapItem::crossEarthPole(mapItem->center(), mapItem->radius())) mapItem->preserveCircleGeometry(pathProjected, mapItem->center(), mapItem->radius()); path.clear(); for (const QDoubleVector2D &c : qAsConst(pathProjected)) - path << mapItem->map()->geoProjection().mapProjectionToGeo(c); + path << p.mapProjectionToGeo(c); QMapbox::Coordinates coordinates; |