summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@qt.io>2017-04-07 13:40:19 +0200
committerPaolo Angelelli <paolo.angelelli@qt.io>2017-04-12 13:30:59 +0000
commite81ba34a98b259723e783e2d2df4321309992291 (patch)
tree4b8263cf08657d31fbfc7fed40b8824a91c24d52
parent15ceb0279c46e286116a93b61f442de0105fcd0c (diff)
downloadqtlocation-e81ba34a98b259723e783e2d2df4321309992291.tar.gz
Allow overzooming when setting zoomLevel directly in a Map
This patch moves the lower/upper bound check on setZoom from QDeclarativeGeoMap to the gesture area, allowing to set higher zoom levels than the maximumZoomLevel when setting Map.zoomLevel directly, for the map types that support overzoom. This is now safe as the bound check is introduced in the tile fetcher, so no invalid tiles will be requested, and is beneficial when combining layers supporting different maximum zoom levels. Change-Id: I08ee9c282ee2ebc1dafa3c68a238b93ffbc1ba02 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
-rw-r--r--src/location/declarativemaps/qdeclarativegeomap.cpp7
-rw-r--r--src/location/declarativemaps/qquickgeomapgesturearea.cpp5
-rw-r--r--src/location/maps/qgeocameracapabilities.cpp32
-rw-r--r--src/location/maps/qgeocameracapabilities_p.h3
-rw-r--r--src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp1
-rw-r--r--src/plugins/geoservices/mapbox/qgeotiledmappingmanagerenginemapbox.cpp1
-rw-r--r--src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp1
-rw-r--r--src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.cpp1
8 files changed, 43 insertions, 8 deletions
diff --git a/src/location/declarativemaps/qdeclarativegeomap.cpp b/src/location/declarativemaps/qdeclarativegeomap.cpp
index 3255a0f5..e4bf10a6 100644
--- a/src/location/declarativemaps/qdeclarativegeomap.cpp
+++ b/src/location/declarativemaps/qdeclarativegeomap.cpp
@@ -865,7 +865,7 @@ void QDeclarativeGeoMap::setMinimumZoomLevel(qreal minimumZoomLevel, bool userSe
m_gestureArea->setMinimumZoomLevel(minimumZoomLevel);
- if (zoomLevel() < minimumZoomLevel)
+ if (zoomLevel() < minimumZoomLevel && (m_gestureArea->enabled() || !m_cameraCapabilities.overzoomEnabled()))
setZoomLevel(minimumZoomLevel);
if (oldMinimumZoomLevel != minimumZoomLevel)
@@ -908,7 +908,7 @@ void QDeclarativeGeoMap::setMaximumZoomLevel(qreal maximumZoomLevel, bool userSe
m_gestureArea->setMaximumZoomLevel(maximumZoomLevel);
- if (zoomLevel() > maximumZoomLevel)
+ if (zoomLevel() > maximumZoomLevel && (m_gestureArea->enabled() || !m_cameraCapabilities.overzoomEnabled()))
setZoomLevel(maximumZoomLevel);
if (oldMaximumZoomLevel != maximumZoomLevel)
@@ -947,7 +947,8 @@ void QDeclarativeGeoMap::setZoomLevel(qreal zoomLevel)
bool centerHasChanged = false;
if (m_initialized) {
- m_cameraData.setZoomLevel(qBound(minimumZoomLevel(), zoomLevel, maximumZoomLevel()));
+ m_cameraData.setZoomLevel(qBound<qreal>(m_cameraCapabilities.overzoomEnabled() ? 0 : minimumZoomLevel(), zoomLevel,
+ m_cameraCapabilities.overzoomEnabled() ? 30 : maximumZoomLevel()));
m_maximumViewportLatitude = m_map->maximumCenterLatitudeAtZoom(m_cameraData);
QGeoCoordinate coord = m_cameraData.center();
coord.setLatitude(qBound(-m_maximumViewportLatitude, coord.latitude(), m_maximumViewportLatitude));
diff --git a/src/location/declarativemaps/qquickgeomapgesturearea.cpp b/src/location/declarativemaps/qquickgeomapgesturearea.cpp
index 3511226c..992fa21e 100644
--- a/src/location/declarativemaps/qquickgeomapgesturearea.cpp
+++ b/src/location/declarativemaps/qquickgeomapgesturearea.cpp
@@ -949,7 +949,8 @@ void QQuickGeoMapGestureArea::handleWheelEvent(QWheelEvent *event)
const QPointF &preZoomPoint = event->posF();
const double zoomLevelDelta = event->angleDelta().y() * qreal(0.001);
- m_declarativeMap->setZoomLevel(m_declarativeMap->zoomLevel() + zoomLevelDelta);
+ // Gesture area should always honor maxZL, but Map might not.
+ m_declarativeMap->setZoomLevel(qMin<qreal>(m_declarativeMap->zoomLevel() + zoomLevelDelta, maximumZoomLevel()));
const QPointF &postZoomPoint = m_map->geoProjection().coordinateToItemPosition(wheelGeoPos, false).toPointF();
if (preZoomPoint != postZoomPoint) // need to re-anchor the wheel geoPos to the event position
@@ -1590,7 +1591,7 @@ void QQuickGeoMapGestureArea::updatePinch()
qreal perPinchMinimumZoomLevel = qMax(m_pinch.m_zoom.m_start - m_pinch.m_zoom.maximumChange, m_pinch.m_zoom.m_minimum);
qreal perPinchMaximumZoomLevel = qMin(m_pinch.m_zoom.m_start + m_pinch.m_zoom.maximumChange, m_pinch.m_zoom.m_maximum);
newZoomLevel = qMin(qMax(perPinchMinimumZoomLevel, newZoomLevel), perPinchMaximumZoomLevel);
- m_declarativeMap->setZoomLevel(newZoomLevel);
+ m_declarativeMap->setZoomLevel(qMin<qreal>(newZoomLevel, maximumZoomLevel()));
m_pinch.m_zoom.m_previous = newZoomLevel;
}
}
diff --git a/src/location/maps/qgeocameracapabilities.cpp b/src/location/maps/qgeocameracapabilities.cpp
index f9eecbf8..d5a2f11e 100644
--- a/src/location/maps/qgeocameracapabilities.cpp
+++ b/src/location/maps/qgeocameracapabilities.cpp
@@ -74,6 +74,7 @@ public:
int tileSize_;
double minimumFieldOfView_;
double maximumFieldOfView_;
+ bool overzoomEnabled_;
};
QGeoCameraCapabilitiesPrivate::QGeoCameraCapabilitiesPrivate()
@@ -87,7 +88,8 @@ QGeoCameraCapabilitiesPrivate::QGeoCameraCapabilitiesPrivate()
maxTilt_(0.0),
tileSize_(256),
minimumFieldOfView_(45.0), // Defaulting to a fixed FOV of 45 degrees. Too large FOVs cause the loading of too many tiles
- maximumFieldOfView_(45.0) {}
+ maximumFieldOfView_(45.0),
+ overzoomEnabled_(false) {}
QGeoCameraCapabilitiesPrivate::QGeoCameraCapabilitiesPrivate(const QGeoCameraCapabilitiesPrivate &other)
@@ -102,7 +104,8 @@ QGeoCameraCapabilitiesPrivate::QGeoCameraCapabilitiesPrivate(const QGeoCameraCap
maxTilt_(other.maxTilt_),
tileSize_(other.tileSize_),
minimumFieldOfView_(other.minimumFieldOfView_),
- maximumFieldOfView_(other.maximumFieldOfView_) {}
+ maximumFieldOfView_(other.maximumFieldOfView_),
+ overzoomEnabled_(other.overzoomEnabled_){}
QGeoCameraCapabilitiesPrivate::~QGeoCameraCapabilitiesPrivate() {}
@@ -123,6 +126,7 @@ QGeoCameraCapabilitiesPrivate &QGeoCameraCapabilitiesPrivate::operator = (const
tileSize_ = other.tileSize_;
minimumFieldOfView_ = other.minimumFieldOfView_;
maximumFieldOfView_ = other.maximumFieldOfView_;
+ overzoomEnabled_ = other.overzoomEnabled_;
return *this;
}
@@ -139,7 +143,8 @@ bool QGeoCameraCapabilitiesPrivate::operator == (const QGeoCameraCapabilitiesPri
&& (maxTilt_ == rhs.maxTilt_)
&& (tileSize_ == rhs.tileSize_)
&& (minimumFieldOfView_ == rhs.minimumFieldOfView_)
- && (maximumFieldOfView_ == rhs.maximumFieldOfView_));
+ && (maximumFieldOfView_ == rhs.maximumFieldOfView_)
+ && (overzoomEnabled_ == rhs.overzoomEnabled_));
}
/*!
@@ -430,5 +435,26 @@ double QGeoCameraCapabilities::maximumFieldOfView() const
return d->maximumFieldOfView_;
}
+/*!
+ Sets whether overzooming is supported by the associated plugin.
+
+ \since 5.9
+*/
+void QGeoCameraCapabilities::setOverzoomEnabled(bool overzoomEnabled)
+{
+ d->overzoomEnabled_ = overzoomEnabled;
+ d->valid_ = true;
+}
+
+/*!
+ Returns whether overzooming is supported by the associated plugin.
+
+ \since 5.9
+*/
+bool QGeoCameraCapabilities::overzoomEnabled() const
+{
+ return d->overzoomEnabled_;
+}
+
QT_END_NAMESPACE
diff --git a/src/location/maps/qgeocameracapabilities_p.h b/src/location/maps/qgeocameracapabilities_p.h
index 099ad76d..d0f69229 100644
--- a/src/location/maps/qgeocameracapabilities_p.h
+++ b/src/location/maps/qgeocameracapabilities_p.h
@@ -100,6 +100,9 @@ public:
void setMaximumFieldOfView(double maximumFieldOfView);
double maximumFieldOfView() const;
+ void setOverzoomEnabled(bool overzoomEnabled);
+ bool overzoomEnabled() const;
+
bool isValid() const;
private:
diff --git a/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp b/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
index 3b06d237..7a92ea23 100644
--- a/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+++ b/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
@@ -101,6 +101,7 @@ GeoTiledMappingManagerEngineEsri::GeoTiledMappingManagerEngineEsri(const QVarian
cameraCaps.setMaximumTilt(80);
cameraCaps.setMinimumFieldOfView(20.0);
cameraCaps.setMaximumFieldOfView(120.0);
+ cameraCaps.setOverzoomEnabled(true);
setCameraCapabilities(cameraCaps);
setTileSize(QSize(256, 256));
diff --git a/src/plugins/geoservices/mapbox/qgeotiledmappingmanagerenginemapbox.cpp b/src/plugins/geoservices/mapbox/qgeotiledmappingmanagerenginemapbox.cpp
index 090ba310..da6c9579 100644
--- a/src/plugins/geoservices/mapbox/qgeotiledmappingmanagerenginemapbox.cpp
+++ b/src/plugins/geoservices/mapbox/qgeotiledmappingmanagerenginemapbox.cpp
@@ -56,6 +56,7 @@ QGeoTiledMappingManagerEngineMapbox::QGeoTiledMappingManagerEngineMapbox(const Q
cameraCaps.setMaximumTilt(80);
cameraCaps.setMinimumFieldOfView(20.0);
cameraCaps.setMaximumFieldOfView(120.0);
+ cameraCaps.setOverzoomEnabled(true);
setCameraCapabilities(cameraCaps);
setTileSize(QSize(256, 256));
diff --git a/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp b/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp
index ca83dc30..4a987800 100644
--- a/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp
+++ b/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp
@@ -85,6 +85,7 @@ QGeoTiledMappingManagerEngineNokia::QGeoTiledMappingManagerEngineNokia(
capabilities.setMaximumTilt(80);
capabilities.setMinimumFieldOfView(20.0);
capabilities.setMaximumFieldOfView(120.0);
+ capabilities.setOverzoomEnabled(true);
setCameraCapabilities(capabilities);
setTileSize(QSize(256, 256));
diff --git a/src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.cpp b/src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.cpp
index 9a1a0e47..2f2d9c80 100644
--- a/src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.cpp
+++ b/src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.cpp
@@ -63,6 +63,7 @@ QGeoTiledMappingManagerEngineOsm::QGeoTiledMappingManagerEngineOsm(const QVarian
cameraCaps.setMaximumTilt(80);
cameraCaps.setMinimumFieldOfView(20.0);
cameraCaps.setMaximumFieldOfView(120.0);
+ cameraCaps.setOverzoomEnabled(true);
setCameraCapabilities(cameraCaps);
setTileSize(QSize(256, 256));