aboutsummaryrefslogtreecommitdiffstats
path: root/mobile-widgets/qml/MapWidget.qml
diff options
context:
space:
mode:
Diffstat (limited to 'mobile-widgets/qml/MapWidget.qml')
-rw-r--r--mobile-widgets/qml/MapWidget.qml45
1 files changed, 43 insertions, 2 deletions
diff --git a/mobile-widgets/qml/MapWidget.qml b/mobile-widgets/qml/MapWidget.qml
index cdfa25d79..7c0f9a691 100644
--- a/mobile-widgets/qml/MapWidget.qml
+++ b/mobile-widgets/qml/MapWidget.qml
@@ -181,8 +181,49 @@ Item {
mapAnimationZoomOut.stop()
}
- function centerOnRectangle(topLeft, bottomRight, center) {
- // TODO
+ function centerOnRectangle(topLeft, bottomRight, centerRect) {
+ stopZoomAnimations()
+ newCenter = centerRect
+ if (newCenter.latitude === 0.0 && newCenter.longitude === 0.0) {
+ newZoom = 2.6
+ newZoomOut = newZoom
+ } else {
+ var centerStored = QtPositioning.coordinate(center.latitude, center.longitude)
+ var zoomStored = zoomLevel
+ var ptCenter
+ var ptTopLeft
+ var ptBottomRight
+ // calculate zoom out
+ newZoomOut = zoomLevel
+ while (zoomLevel > minimumZoomLevel) {
+ ptCenter = fromCoordinate(centerStored)
+ ptTopLeft = fromCoordinate(topLeft)
+ ptBottomRight = fromCoordinate(bottomRight)
+ if (pointIsVisible(ptCenter) && pointIsVisible(ptTopLeft) && pointIsVisible(ptBottomRight)) {
+ newZoomOut = zoomLevel
+ break
+ }
+ zoomLevel--
+ }
+ // calculate zoom in
+ center = newCenter
+ zoomLevel = maximumZoomLevel
+ while (zoomLevel > minimumZoomLevel) {
+ ptTopLeft = fromCoordinate(topLeft)
+ ptBottomRight = fromCoordinate(bottomRight)
+ if (pointIsVisible(ptTopLeft) && pointIsVisible(ptBottomRight)) {
+ newZoom = zoomLevel
+ break
+ }
+ zoomLevel--
+ }
+ if (newZoom > defaultZoomIn)
+ newZoom = defaultZoomIn
+ zoomLevel = zoomStored
+ center = centerStored
+ }
+ mapAnimationZoomIn.restart()
+ mapAnimationZoomOut.stop()
}
function deselectMapLocation() {